+ Start a Discussion
Megha Mittal 19Megha Mittal 19 

Close a lightning quick action component in the initialize method

Hi,

I have a requirement where on click on a lightning quick action, a mailto: command should run and the user should be able to view a mail option. 
I have added the mailto to a lightning component urlevent. once this is run, I want the quickaction modal to close. 
I have tried $A.get("e.force:closeQuickAction").fire() but the modal was still visible.
Can anyone tell me how to go ahead with this.
Raj VakatiRaj Vakati
Refer this link  .. 

https://developer.salesforce.com/forums/?id=9060G000000Bi9sQAC
sachin pawar 72sachin pawar 72
Create navigatecmp component

<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" >
    <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
     
    <aura:handler event="aura:doneRendering" action="{!c.handleClose}"/>
    <lightning:navigation aura:id="navService"/>
</aura:component>

navigatecmpController.js

({
    doInit : function(component, event, helper) {
        var pageReference = {
            type: 'standard__component',
            attributes: {
                componentName: 'c__helloTarget',
            },
            state: {
                "c__title": "John"
            }
        };
        
        const navService = component.find('navService');
        // const pageReference = component.get('v.pageReference');
        const handleUrl = (url) => {
            $A.get("e.force:closeQuickAction").fire();
            window.open(url);
        };
            const handleError = (error) => {
            $A.get("e.force:closeQuickAction").fire();
            console.log(error);
        };
            navService.generateUrl(pageReference).then(handleUrl, handleError);
        },
    handleClose : function(component, event, helper) {
                $A.get("e.force:closeQuickAction").fire();
            }
            
        })