Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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.

share|improve this question
    
Thank you for your contribution Peter, but that was my first assumption (and what would make my life easier) and it has proved wrong. –  ricardomartins Feb 25 '13 at 12:25

1 Answer 1

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?

share|improve this answer
    
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 :) –  ricardomartins Feb 27 '13 at 9:52
    
Hi @ricardomartins did this help you out? –  Andrew Fawcett Apr 14 '13 at 19:40

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.