0

We're in transition from classic to lightning and are working to update several of our javascript buttons over into lightning components, quick actions, etc.

I have one javascript button that calls a visualforce page that launches a flow. If I convert this over to a quick action, I like how it displays as a model popup within the page instead of opening in a new tab. My beef is the placement of the action as it's collapsed where the standard buttons show.

enter image description here

To help keep these visible, I have created a custom button panel (lightning component) to highlight some of our most frequently used custom actions. My challenge is that I'm having trouble calling that quick action from my custom button panel.

Here's my Custom Object Action: enter image description here

Here's my component code:

    <aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader,lightning:isUrlAddressable" >
    <lightning:workspaceAPI aura:id="workspace"/>
    <lightning:quickActionAPI aura:id="quickActionAPI"/>

    <!--Used to store data within an aura component-->
    <aura:attribute name="helpTicket" type="Object"/>
    <aura:attribute name="helpTicketRecord" type="Help_Ticket__c" default="{'sObjectType': 'Account'}"/> 

    <force:recordData aura:Id="recordData" recordId="{!v.recordId}" fields="['Account__c', 'OwnerId']"
                      targetRecord="{!v.helpTicket}" targetFields="{!v.helpTicketRecord}" mode="EDIT"/>

    <div>
        <lightning:button variant="brand" class="paylocity-orange" label="Accept" onclick="{!c.acceptHelpTicket}"/>
        <lightning:button variant="brand" class="paylocity-orange" label="Close Help Ticket" onclick="{!c.closeHelpTicket}"/>        
    </div>
</aura:component>

Here's the controller code I thought for sure would work:

closeHelpTicket : function(component, event, helper) {        
    var actionAPI = component.find("quickActionAPI");
    var fields = {Id: {value: component.get("v.recordId")}};
    var args = {actionName: "Help_Ticket__c.Close_Help_Ticket_3", entityName: "Help_Ticket__c", targetFields: fields};
    actionAPI.setActionFieldValues(args).then(function(result) {
        actionAPI.invokeAction(args);
        console.log('closeHelpTicket action called');
        //Action selected; show data and set field values
    }).catch(function(e) {
        if(e.errors) {
            console.log(e.errors);
        }
    });
}

Here's what I'm seeing from the console after I click the button from the console component. enter image description here

What am I missing?

  • So what problem are you facing? Were you able to open quick action? – Pranay Jaiswal Mar 11 at 14:28
  • The quick action from the button panel isn't working. It doesn't open a window or anything. – Kelly Shoemake Mar 11 at 14:33
  • do you see any erros in console? Also Do you just want that popup to open right and not call save /submit automatically – Pranay Jaiswal Mar 11 at 14:34
  • The only thing I see that pops up is "We can't execute the API because the parent record isn't selected." – Kelly Shoemake Mar 11 at 14:40
  • Updated answer. – Pranay Jaiswal Mar 11 at 15:09
1

You can't call a quick action if you don't have that Quick Action added to the page -layout.

You have to put that quickAction on the page -layout for the quickActionAPI to open it.

Src: How to fire global action from a Lightning Component

  • The quick action is supposed to launch a flow and the flow controls the logic on fields to be presented to the user for update. Are there values I need to supply for launching a flow? All the examples I saw, if I set a value for them then it was a statically set value. – Kelly Shoemake Mar 11 at 14:56
  • Can you see if the quick action opened? – Pranay Jaiswal Mar 11 at 14:57
  • I'll update my original post with info from the console. As far as I can tell, it doesn't open. – Kelly Shoemake Mar 11 at 14:59
  • The quick action is on the page layout as you can see from my screenshot. Also, I should not that this is not a global action, it is a custom object action. – Kelly Shoemake Mar 11 at 15:27
1

In this code , the fields defined in the force:recordData is not the correct way. Check the code below: Component:->

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:attribute name="caseRecord" type="sObject"/>
    <aura:attribute name="recordError" type="String"/>

     <force:recordData aura:id="recordLoader"
                      recordId="{!v.recordId}"
                      fields="Id, Status"                
                      targetFields="{!v.caseRecord}"
                      targetError="{!v.recordError}"
                      />

</aura:component>

Also check the controller code below:

Controller:->

({
    callRescheduleCaseAction : function( cmp, event, helper ) {
        var actionAPI = cmp.find("quickActionAPI");
        var fields = { relatedTo : { Id : "recordId" } };
        var args = { actionName : "Case.Reschedule_Kit", 
                     entityName : "Case",
                     targetFields : fields };
        actionAPI.setActionFieldValues(args).then(function() {
            actionAPI.invokeAction(args);
        }).catch(function(e) {
            console.error(e.errors);
        });
    }

})

Let me know if you have any further questions on this.

  • This isn't related to my question. After going through some support tickets with salesforce, aura doesn't support calling a record quick action. I ended up having to call the flow directly from the controller and building out the modal in the cmp for it to render in. The recordData definition is fine. It needs the mode="EDIT" argument for me to complete other aura methods that I defined. – Kelly Shoemake Nov 5 at 14:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.