I have a Canvas App in a Lightning Component that I'd like to display in a Modal/Overlay when a User clicks on a button (within a different Lightning Component). The Canvas App component uses the force:hasRecordId to pass to a controller. How can I get the button click to launch in a new window while still passing the RecordId as needed?

I've got the below Component/Controller working fine with the Lightning UI, just need to be able to launch the Canvas in a Model/Overlay:


<aura:component implements="flexipage:availableForAllPageTypes,force:apphostable,lightning:isUrlAddressable,flexipage:availableForRecordHome,force:hasRecordId" access="global" controller="AgencyLoanCanvasHandler">
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="loanParams" type="String" access="global"/>
            <force:canvasApp developerName="Agency_Loan_Canvas_App" parameters="{!v.loanParams}" width="100%"/>

JS Controller

    doInit : function(component, event, helper) {        
        var loanId = component.get("v.recordId");
        var action = component.get("c.getLoanParameters");  
            "strOppId" : loanId
        action.setCallback(this, function(response) {
            var state = response.getState();
            if(component.isValid() && state === "SUCCESS"){
                var result = response.getReturnValue();
                var loanParam = result;
            else if(state === "ERROR") {
                var errors = response.getError();
                console.log("An error ocurred");

Apex Controller

public class AgencyLoanCanvasHandler {

    public static String getLoanParameters(String strOppId) {

        Opportunity opp = [Select Id, Name, RecordType.Name, Loan_Number_formula__c, User_Email__c, Amount From Opportunity Where Id = :strOppId];

        String userId = userInfo.getUserId();
        String Amount = string.valueOf(opp.Amount);

        JSONGenerator gen = JSON.createGenerator(true);
        gen.writeStringField('loanNumber', opp.Loan_Number_formula__c);
        gen.writeStringField('loanId', opp.Id);
        gen.writeStringField('loanName', opp.Name);
        gen.writeStringField('userEmail', opp.User_Email__c);
        gen.writeStringField('userId', userId);
        gen.writeStringField('RecordType', opp.RecordType.Name);
        gen.writeStringField('Amount', Amount);

        return gen.getAsString();



Trying to call the Canvas from a button on a separate component, need to be able to pass the RecordId

  • How the canvas app is created, is it embedding the different salesforce org page or some other system page. Surrounding code could also help here to understand and dig deeper. Dec 1, 2019 at 5:07

1 Answer 1


Decided to use a standard Modal in a child component to display.

You must log in to answer this question.

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