No Results
Search Tips:
- Please consider misspellings
- Try different search keywords
Tell Me More: Get Context in your Canvas App
The Force.com Canvas SDK provides calls and objects that let you retrieve context
information about the application and the current user from Salesforce.
Getting Context
When you authenticate your canvas app using signed request, you get the CanvasRequest object (which contains the Context object) as part of the POST to the canvas app URL. If you’re authenticating using OAuth, or if you want to make a call to get context information, you can do so by making a JavaScript call. You can use this information to make subsequent calls for information and code your app so that it appears completely integrated with the Salesforce1 user interface.
The following code sample is an example of a JavaScript call to get context. This code creates a link with the text “Get Context” which then calls the Sfdc.canvas.client.ctx function.
Context Objects
When you make a call to get context in your canvas app, you get
a CanvasRequest object back in the response. This object contains
all the contextual information about the application and the user.
The context objects include:
| Object | Description |
|---|---|
| CanvasRequest | Returns the Context and Client objects. |
| Client | Returns context information about the client app. |
| Context | Returns information about the consumer of the canvas app. Contains the Application, Environment, Links, Organization, and User objects. |
| Application | Returns information about the canvas app, such as version, access method, URL, and so on. |
| Environment | Returns information about the environment, such as location, UI theme, and so on. |
| Links | Returns links, such as the metadata URL, user URL, Chatter groups URL, and so on. You can use these links to make calls into Salesforce from your app. |
| Organization | Returns information about the organization, such as name, ID, currency code, and so on. |
| User | Returns information about the currently logged-in user, such as locale, name, user ID, email, and so on. |
This code snippet shows an example of the CanvasRequest
object:
For more information about context objects and the Force.com Canvas SDK, see the Force.com Canvas Developer’s Guide.