I have created a canvas app and am hosting it on Heroku. I then added this app to a Visualforce page, along with the required Salesforce SDK (which is hosted on heroku).

Because this app will be used on different devices (mainly mobile) I added the autogrow function, however I cannot seem to get it to work. My visualforce page code is shown below:

    <apex:page controller="connectDataController" showHeader="false" sidebar="false" standardStylesheets="true" docType="html-5.0" language="en-US" applyHtmlTag="false">      

<apex:canvasApp canvasId="mycanvas0" developerName="x" id="mycanvas0" /> 

<script> type="text/javascript" src="/sdk/js/controller.js"  </script>
<script> type="text/javascript" src="/sdk/js/client.js" </script> 
<script> type="text/javascript" src="/sdk/js/canvas-all.js" </script> 

    // Turn on auto grow with default settings.
    Sfdc.canvas(function() {
    alert("In function");
    var sr = JSON.parse('<%-JSON.stringify(canvasDetails)%>');
    console.log("CONSOLE.LOG FROM VF : " + sr.userId);
    alert("after var");

    alert("Test End");
</script> </apex:page>

When I visit the page, the canvas app defaults to the standard size, and only the alerts saying "In function" and "Test End" are displayed.

Anybody have any ideas of what might be going wrong?


  • Have you tried this - Sfdc.canvas.client.autogrow(sr.client, true, 100); ? to autogrow in 100 ms ? I know its not your requirement however just trial.. Jul 30, 2014 at 23:30

1 Answer 1


Request for autogrow should happen in Heroku not in the Visualforce page. The canvas app (the iFrame) needs to tell the parent (Visualforce page) that it wants to grow. You should add below code on Heroku side

var sr = JSON.parse('<%=signedRequestJson%>');

You must log in to answer this question.

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