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
Nilesh SoorNilesh Soor 

Canvas app resize issue

Hi,

I have embeded external node/react application into Salesforce's Tab using Canvas/Visual force page.
Visual Force Page Code:
<apex:page sidebar="false" >

       <div id="myID"></div>
       <apex:canvasApp applicationName="MyApp" containerId="myID" width="100%" maxHeight="infinite"/>
</apex:page>


Some of pages in my external application is having more than 2000px height.
I tried using Sfdc.canvas.client.resize feature but doesnt worked!

am I doing something wrong ?? Please suggest.

Thanks,
Nilesh
 
SandhyaSandhya (Salesforce Developers) 
Hi,

Refer below note from below link.

For resize functions to work with your canvas app, you must declare a DOCTYPE at the top of any HTML pages that are associated with the app. For example: <!DOCTYPE html>.

https://developer.salesforce.com/docs/atlas.en-us.platform_connect.meta/platform_connect/canvas_app_resizing.htm
 
https://developer.salesforce.com/docs/atlas.en-us.platform_connect.meta/platform_connect/canvas_app_resize_code_example.htm
 
https://salesforce.stackexchange.com/questions/55564/canvas-app-resize-limiting-to-2000px-height
 
Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.

Best Regards,
​Sandhya
 
Nilesh SoorNilesh Soor
Thanks Sandhya for quick response!
Please find code below:

<!DOCTYPE html>
<html lang = "en">
   <head>
      <script type="text/javascript" src="js/canvas-all.js"></script>
      <script>
          $(document).ready(function(){
              var request1 = '<%=signed_req  %>';
              alert(Sfdc.canvas.client.size().heights.pageHeight)
              Sfdc.canvas.client.resize(request1.client,{height : "20px"});
              alert(Sfdc.canvas.client.size().heights.pageHeight)
         });


I already declared a DOCTYPE at the top of myHTML pages.
first alert showing me 900px
after setting custome height>>

second alert showing 20px
but the height is not getting reflected onto the page.

Thanks,
Nilesh