Prerequisites
Create the App
Set the Canvas App Location for External Client Apps
Set the Canvas App Location for Connected Apps
Lightning Component Code Examples
Canvas Limits
Previous Versions
Specify where your canvas app can display to a user in Salesforce via an external client app.
In Lightning Experience, from Setup, search for External Client App in the Quick Find box, then select External Client App Manager.
In the related list, click the dropdown arrow for the app you just created and then click Edit Settings.
In the Canvas Apps Settings section, in the Locations field, select where the canvas app can appear to the user. For this example, select Lightning Component.
force:canvasApp component.<apex:canvasApp> component to expose a canvas app on a Visualforce page, be sure to select this location for the canvas app; otherwise, you’ll receive an error.Click Save.
Embed the canvas app in a Lightning component.
Click File | New | Lightning Component.
Enter myCanvasApp in the Name field.
Copy and paste this code.
1<!-- myCanvasApp.cmp -->
2<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId" access="global" >
3 <aura:attribute name="canvasParameters" type="string" />
4 <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
5
6 <aura:if isTrue="{!v.canvasParameters}">
7 <force:canvasApp developerName="Hello_World"
8 height="400px" width="750px"
9 parameters="{!v.canvasParameters}"/>
10 </aura:if>
11</aura:component>To verify the developerName value of your canvas app, in Setup, go to External Client App Manager and click on your app name. Then click the Settings tab and verify the API Name.
In the controller file, copy and paste this code.
1({
2 doInit : function(cmp, evt, helper) {
3 var recordId = cmp.get("v.recordId");
4 cmp.set("v.canvasParameters", JSON.stringify({
5 recordId: recordId
6 }));
7 }
8})Save your changes.
Display the Lightning component on a record.
Navigate to the record page you want to customize, for example, a contact record page.
Click the gear icon and select Edit Page.
Find the myCanvasApp custom component and drag it to where you want it on the Lightning page. Save your changes.
Activate the page. Click Assign as Org Default, and then click Next.
Your canvas app is now displayed on contact record pages.
See Also