8

Im trying invoke a SendEmail global action from a custom button inside Account page. I need that this button have the same behavior that hitting on Gear icon. Apparenly the code below just opens the SendEmail on activity screen and not as clicking from gear icon.

component

<aura:component implements="flexipage:availableForAllPageTypes" access="global" >
    <lightning:quickActionAPI aura:id="quickActionAPI" />
    <div>
        <lightning:button label="Send Email" onclick="{!c.sendEmailAction}"/>
    </div>
</aura:component>

Controller js

sendEmailAction : function( cmp, event, helper) {
        var actionAPI = cmp.find("quickActionAPI");

    var args = {actionName: "SendEmail"};
    actionAPI.selectAction(args).then(function(result){

        //Action selected; show data and set field values
        console.log('test', result);

    }).catch(function(e){
        if(e.errors){
            console.log('test error', e);
            //If the specified action isn't found on the page, show an error message in the my component 
        }
    });
}

Is possible the code above open a global action as bellow:

enter image description here

Thank you in advance!

1 Answer 1

1

You have to specify the recordId as your argument.

 var args = {actionName: "SendEmail",recordId:cmp.get('v.recordId')};

Also in your component, you have implement an extra interface force:hasRecordId to get recordId from the detail page

<aura:component implements="flexipage:availableForAllPageTypes,force:hasRecordId" access="global" >
    <lightning:quickActionAPI aura:id="quickActionAPI" />
    <div>
        <lightning:button label="Send Email" onclick="{!c.sendEmailAction}"/>
    </div>
</aura:component>

Src: https://developer.salesforce.com/docs/component-library/bundle/lightning:quickActionAPI/documentation

1
  • 1
    Thank you Pranay, but I already tried it, and do not work for me, the component tries open a email action into acticvity page and not as popup as when clicking in gear icon. Commented Dec 3, 2018 at 15:22

You must log in to answer this question.

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