3

enter image description hereIssue facing while using lightning overlay:

1) when I override the Quick Action with Lightning overlay Component there are two overlay showing one is quick action overlay and other is the standard quick action modal.Is there is any way to avoid standard modal of quick action.Right now I used the close quick action event during doInit of the overlay component.

2)When I click on "OK" Button I am redirecting to the account record.When I redirect to account record Page I am getting "Page does not exists" error popup.

Overlay component:

    <aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
<aura:handler name="init" value="{! this }" action="{! c.doInit }"/>
<aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
<lightning:overlayLibrary aura:id="overlayLib"/>    
</aura:component>

({
    doInit : function(component, event, helper) {
    window.setTimeout(function(){
                    $A.get("e.force:closeQuickAction").fire(); 
        }, 100);
    var modalBody;
    var modalFooter;
    $A.createComponents([
        ["c:modalContent",{}],
        ["c:modalFooter",{"recordId":component.get("v.recordId")}]
    ],
    function(components, status){
        if (status === "SUCCESS") {
            modalBody = components[0];
            modalFooter = components[1];
            component.find('overlayLib').showCustomModal({
               header: "Application Confirmation",
               body: modalBody, 
               footer: modalFooter,
               showCloseButton: true,
               closeCallback: function() {
                   //alert('You closed the alert!');
                   var sObjectEvent = $A.get("e.force:navigateToSObject");
                    sObjectEvent.setParams({
                        "recordId": component.get("v.recordId"),
                        "slideDevName": 'detail'
                    })
                    sObjectEvent.fire();
               }
           })
        }
    }
   );   
    }
})

Modal Content:

<aura:component >
    <lightning:icon size="medium" iconName="action:approval" alternativeText="Approved" />
    Your application has been approved.
</aura:component>

Modal footer:

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,forceCommunity:availableForAllPageTypes,force:lightningQuickAction" access="global" >
    <aura:dependency resource="markup://force:navigateToSObject" type="EVENT"/>
    <aura:attribute name="recordId" type="String"/>
    <lightning:button name="cancel" label="Cancel" onclick=""/>
    <lightning:button name="ok" label="OK" variant="brand" onclick="{!c.handleOK}"/>
</aura:component>

({
    handleOK : function(component, event, helper) {
                   console.log('recordId----'+component.get("v.recordId"));
                   var sObjectEvent = $A.get("e.force:navigateToSObject");
                    sObjectEvent.setParams({
                        "recordId": component.get("v.recordId"),
                        "slideDevName": 'detail'
                    })
                    sObjectEvent.fire();
    }
})

1 Answer 1

0

The event navigateToSObject is getting fired twice, that is causing this issue.

  1. In handleOk function
  2. In Close callback function in overlay component

You can safely remove the code for close callback function and that should solve your issue.

**closeCallback: function() {
               //alert('You closed the alert!');
               //var sObjectEvent = $A.get("e.force:navigateToSObject");
                //sObjectEvent.setParams({
                //    "recordId": component.get("v.recordId"),
                //    "slideDevName": 'detail'
                //})
                //sObjectEvent.fire();
           }**
3
  • But I need to redirect to record page when i click the modal close also.For that reason I added it. Jul 1, 2018 at 6:31
  • The reason for "Enter valid url and try again" error is that in the context of "closeCallback" function recordId is not available. Hence redirect is failing. Not sure why you need to do explicit redirects. But other option is to remove close button by setting "showCloseButton" to false and handling redirects using "cancel" handler.
    – MandyKool
    Jul 1, 2018 at 7:28
  • but i need close option in modal i cant remove that Jul 1, 2018 at 7:54

You must log in to answer this question.

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