function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DrewStoddardDrewStoddard 

Accessing the Opportunity ID from inside a Canvas App

We are using the Canvas framework to build our integrated application, a part of which involves modifying the Opportunity detail page to include a new section where our application runs.  We currently have this working so that Canvas connects securely to our application, and displays our UI within the designated window correctly.  We also receive most of the data we need to initialize our application during the Canvas OAuth linkup process, with one exception: we need to know the ID of the Opportunity the user was viewing when our application was launched, but this piece of data is not supplied in the Canvas context object.

 

Can anybody tell us how we might be able to retrieve the Opportunity Id (or Account Id) for the detail screen the user is currently viewing when our application is launched?

 

It seems like a simple task, but we can't find any documentation on how to go about it.

Best Answer chosen by Admin (Salesforce Developers) 
nraghavannraghavan

Try using the "parameters" element. When you specify the apex:canvasApp component, you have an optional element called "parameters." Here you can build a JSON string that is passed in the signed request and the getContext() call. So you could specify the Opportunity ID there and you can parse the JSON and get the context you need.

 

Check out this video for an example: http://www.youtube.com/watch?v=AchJBotmI2s

All Answers

nraghavannraghavan

Try using the "parameters" element. When you specify the apex:canvasApp component, you have an optional element called "parameters." Here you can build a JSON string that is passed in the signed request and the getContext() call. So you could specify the Opportunity ID there and you can parse the JSON and get the context you need.

 

Check out this video for an example: http://www.youtube.com/watch?v=AchJBotmI2s

This was selected as the best answer
DrewStoddardDrewStoddard

Outstanding!  This is exactly what I was looking for put couldn't find any documentation on.  I watched the video and the parameters element meets our needs exactly.  We have the value at the time the connection is made so passing it inside the signed request is straightforward.  Thanks so much for your response.

jhurstjhurst

The full explanation of the "parameters" option (and other Canvas options) are in the Summer '13 Developer Guide - http://www.salesforce.com/us/developer/docs/platform_connect/canvas_framework.pdf

 

Hope this helps.

Jay

Dimple riarDimple riar
I am facing same issue as above. Best Answer seems helpful but the link for video is not working.It is giving error as "Video is Unavailable". Please Help!