[SalesForce] How to fire global action from a Lightning Component

I a not sure if this is possible but I am trying to fire a global action from a lightning component button click. Open to other solutions.

I tried implementing it using the lightning:QuickActionApi. But it doesn't seem to work.
https://developer.salesforce.com/docs/component-library/bundle/lightning:quickActionAPI/documentation

Below is my Component:

<aura:component implements="force:appHostable, flexipage:availableForAllPageTypes, flexipage:availableForRecordHome, force:hasRecordId" access="global">

  <lightning:quickActionAPI aura:id="quickActionAPI" />

      <lightning:button label="Select Update Case Action" onclick="{!c.fireGlobal}" />


</aura:component>

Below is my Controller Code:

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

    var args = { actionName: "NewContact" };
    actionAPI.invokeAction(args);
}

Error message:

{
        actionName:"NewContact",
        errors:["We can’t execute the API because the parent record isn’t selected."],
        parentContext:null,
        success:false,
        targetName:undefined,
        unavailableAction:true
}

Best Answer

I did some trial and error and found that the action has to be on the record page. Once I added the publisher to the lightning page layout and the action to the page layout, I found that it worked.

From what it looks like, this is very limited as you cannot call actions for child records on the parent record page. If there is a way, I would love to get help on it.

Related Topic