6

I'm experimenting with the Canvas feature, and embedding it in a Visualforce page, from where I hoped I would have some control over the canvas.

Now, the apex:canvasApp has a property called parameters and it's description says that they're parameters passed to the canvas app.

When I don't use the parameters attribute the canvas page draws normally, and using firebug I can see the call to the ip address of the canvas app. But for it to be useful to me I need to pass some parameters to the canvas page and when I do use the parameters attribute the canvas simply does not show, and in firebug it does not show any call to the ip of the canvas.

How are these parameters passed or how can one catch them? Using firebug, in the call to the ip of the canvas app, I can't see any of the parameters that I'm trying to pass.

Here's the simple code I'm experimenting with:

<apex:page >
<apex:canvasApp applicationName="Test Canvas" height="400px" width="750px" parameters="{vst_cli: '1293'}" />
</apex:page>

Inside the parameters attribute I've tried some different things:
"{vst_cli: '1293'}"
"{vst_cli: 1293}"
"{'vst_cli': '1293'}"
All of which had the same effect.

Any help or pointers will be welcome.

Thanks in advance.

2
  • Thank you for your contribution Peter, but that was my first assumption (and what would make my life easier) and it has proved wrong. Commented Feb 25, 2013 at 12:25
  • Is your Canvas App using 'Singed Request' ? I've run into this issue as well, did you find a work around? If you pass a null or false or {} or I guess other falsy value to parameters the Canvas app renders but anything else it silently fails to render. Commented May 4, 2020 at 22:47

2 Answers 2

13

Parameters are passed as part of the JSON context structure your Canvas app decodes. See Chapter 6 of the docs, you'll see a parameters example embedded in the context example shown.

Your JSON parameters appear to be correct and as per the documentation you linked to. I've just tried it with one of my CanvasApps and my app does successfully render.

<apex:page >
    <apex:canvasApp developerName="apextools" namespacePrefix="apt" parameters="{param1:'value1',param2:'value2'}"/>
</apex:page>

I was also able to confirm that the JSON parameters did reach my app by debugging it. Just after the JSON in the 'signed_request' parameter is decoded. Can you do the same with your Canvas app? Or are you saying the browser actually never makes the call out? If so, maybe it is an issue on the page, can you simplify it like mine above?

{
"context": {
    "user": {
        // Contents removed for this answer
    },
    "environment": {
        "parameters": {
            "param1": "value1",
            "param2": "value2"
        },
        "dimensions": {
            "width": "800px",
            "height": "900px"
        },
        "locationUrl": "https://apt.na15.visual.force.com/apex/apextool",
        "uiTheme": "Theme3",
        "version": {
            "api": "27.0",
            "season": "SPRING"
        }
    },
    "organization": {
        "name": "Apexcodetool",

Salesforce Canvas SDK Support: It appears that the current Salesforce Canvas SDK does not consider the fact that the 'parameters' structure can be passed in the environment part of the context. Though the Java JSON decoder appears silently ignores it. Not sure if this is the case with your canvas app, maybe it errors deserialising the request context?

2
  • Your answer is very good, I'm still doing some experiments, I'll get back to you as soon as I reach any conclusions. Thanks :) Commented Feb 27, 2013 at 9:52
  • 1
    Hi @ricardomartins did this help you out? Commented Apr 14, 2013 at 19:40
1

I had the same issue where the Canvas call was not being made when I added the "parameters" attribute.

It turned out it was a formatting issue and the documentation is wrong!

The format that worked for me was

parameters="{'fileName':'{!localVar.File_Name__c}'}"

You must log in to answer this question.

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