I am planning on using Canvas to lightweight integrate an external web app. In the documentation (https://resources.docs.salesforce.com/218/latest/en-us/sfdc/pdf/canvas_framework.pdf) I wasn't able to find an example on how to send more heavyweight context data to the Canvas URL endpoint.

I need to seen not only user information but also the current record and a few child records (formatted as JSON) to the Canvas.

How would I do this?

  • 1
    How are you hosting the external web app in salesforce. Is it a standalone tab or a canvas app tag inside a lightning component or a VF page?
    – RedDevil
    May 8, 2019 at 11:03
  • It's Lightning Aura components using force:canvasApp. May 8, 2019 at 11:09
  • 2
    So inside a lightning component you are using a force canvasApp tag correct? sorry for asking i am confirming what you are trying before i put the solution that we did to pass parameters
    – RedDevil
    May 8, 2019 at 11:11
  • Yes that is the plan. On the Home page there is an Aura Component which should have a Canvas tag, but I am looking for a way to pass/send more data to the Canvas. Not only the calling user but also the current record and some other child records. May 8, 2019 at 11:29

2 Answers 2


In the force canvas app there is a attribute parameters which you can use to send parameters as name value pair. documentation here

Object representation of parameters passed to the canvas app. This should be supplied in JSON format or as a JavaScript object literal. Here’s an example of parameters in a JavaScript object literal: {param1:'value1',param2:'value2'}. If not specified, defaults to null.

Component markup code:

  <force:canvasApp developerName="TestCanvas" height="850px" width="100%"
                                             parameters="{!v.canvasParams}" />

Javascript controller code:

var canvasParams = {
                            "userType": "Test",
                            "agencyId": "agencyname"
component.set("v.canvasParams", JSON.stringify(canvasParams));
  • How are those parameter send? Via insecure GET params. Then I can't use them. Can I use POST instead? And is there a size limitation? I also don't get what I need the third code example for. The Apex with the signed request. May 8, 2019 at 11:52
  • 1
    In the connected app you create for the canvas app if you choose signed request as the access method it does a post and not a get. check page page 25, point 13 in the link you have shared in the question, I am not aware of size limitation since its not there in the documentation, the apex code i put in the question was just for illustration on how the parameters are received in the canvas app.
    – RedDevil
    May 8, 2019 at 11:59
  • 1
    Check page 34 from the guide, where it says if you set access to admin pre-approved it always does a post to the canvas app URL
    – RedDevil
    May 8, 2019 at 12:01
  • Sounds convincing. Can you add a bit detail to you Apex code (or remove it from the Answer) please? From which class is it? The VF controller or the custom class for the Canvas Lifecycle? May 8, 2019 at 15:23
  • 1
    removed the apex code part from the answer
    – RedDevil
    May 8, 2019 at 18:23

The maximum size of canvas parameters seems to be 32kB. At least it is documented for the Apex setParametersAsJSON(jsonString) method:

If the provided JSON string exceeds 32KB, a System.CanvasException will be thrown.

(via https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_canvas_EnvironmentContext_setParametersAsJSON.htm)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .