1

First of all, I am quite new to developing Lightning components. In fact, this is my first.

I have created an Aura Component that opens some specific records as sub-tabs in a console. It is working OK, from a component perspective, but I trying to set it as a Quick Action from a button on the Account page.

The component I built from examples has a button display to initiate the component.

My aim is to remove the button & have it initiate the component immediately. So far my attempts have been dismal failures.

Any clues appreciated.

TestComponnet.CMP

<aura:component implements="flexipage:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <lightning:workspaceAPI aura:id="workspace" />
    <lightning:button label="Billing Account Summary" onclick="{! c.openTabWithSubtab }" />
 </aura:component>

TestComponentController.js

({
    openTabWithSubtab : function(component, event, helper) {
        var workspaceAPI = component.find("workspace");
        workspaceAPI.openTab({
            url: '/lightning/r/Account/0011e000005h1l2AAA/view',
            focus: true
        }).then(function(response) {
            workspaceAPI.openSubtab({
                parentTabId: response,
                url: 'https://iagpoc--dev--c.documentforce.com/sfc/servlet.shepherd/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=0681e000000B6GG&operationContext=CHATTER&contentId=05T1e0000019kxV',
                focus: true
            });
        })
        .catch(function(error) {
            console.log(error);
        });
    }
})
2
  • Hey David , thanks for editing, I was trying to work out how to get it correctly formatted.
    – Paul F
    Commented Mar 14, 2021 at 23:09
  • Sure thing! Just wrap each code block in triple backticks (```) on a line by themselves.
    – David Reed
    Commented Mar 14, 2021 at 23:35

1 Answer 1

3

To remove the button, and launch as soon as the modal opens, just use aura:handler instead:

<aura:handler name="init" value="{!this}" action="{!c.openTabWithSubtab}" />

To avoid the modal remaining afterwards, go ahead and close it:

openTabWithSubtab : function(component, event, helper) {
    var workspaceAPI = component.find("workspace");
    workspaceAPI.openTab({
        url: '/lightning/r/Account/0011e000005h1l2AAA/view',
        focus: true
    }).then(function(response) {
        workspaceAPI.openSubtab({
            parentTabId: response,
            url: 'https://iagpoc--dev--c.documentforce.com/sfc/servlet.shepherd/version/renditionDownload?rendition=ORIGINAL_Jpg&versionId=0681e000000B6GG&operationContext=CHATTER&contentId=05T1e0000019kxV',
            focus: true
        });
        // Dismiss the quick action
        $A.get("e.force:closeQuickAction").fire();
    })
    .catch(function(error) {
        console.log(error);
    });
1
  • sfdcfox, Excellent & thanks for your help. Very much appreciated. Your proposed solution is working well & achieving what I need.
    – Paul F
    Commented Mar 15, 2021 at 0:06

You must log in to answer this question.

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