function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Neetu GoyalNeetu Goyal 

lightning component action issue

Hi! I am working on a lightning component action to update a checkbox if the opportunity is won. The button is working fine, but there is an extra blank pop up with the alert message. I need to show just the alert message, not the blank screen. Can anyone help. Thank you!

({
 doInit : function(component,event,helper){
        $A.get("e.force:closeQuickAction").fire();
      var id = component.get("v.recordId");
      var action = component.get("c.updateOpportunity");
        action.setParams({
               "opportunityId" : id
        });
        
        action.setCallback(this, function(response) {
            if (response.getState() == "SUCCESS") {
                console.log("Save completed successfully.");
               //$A.get("e.force:closeQuickAction").fire();
                alert('Contracted!!Please refresh your screen');
             $A.get("e.force:closeQuickAction");
                  $A.get('e.force:refreshView').fire();
            }else{
                alert('Opportunity is not won!!!');
            }
             var dismissActionPanel = $A.get("e.force:closeQuickAction");
             dismissActionPanel.fire();
        });   
             $A.enqueueAction(action);
      },
     cancel : function(component, event, helper){  
     //$A.get('e.force:refreshView').fire();
      $A.get("e.force:closeQuickAction").fire();
}, 
})

Component-

<aura:component controller="generateContractClass" implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionWithoutHeader" access="global">
    <aura:attribute name="recordId" type="String" />
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>     
   </aura:component>

Blank pop up that I need to remove-
Blank Screen
 
AnudeepAnudeep (Salesforce Developers) 
Hi Neetu, 

I recommend leveraging the lightning:notificationsLibrary because 
Notices inherit styling from prompts in the Lightning Design System and doesn't come with such problems

For sample code, please refer the above documentation
 
({
    handleShowNotice : function(component, event, helper) {
        component.find('notifLib').showNotice({
            "variant": "error",
            "header": "Something has gone wrong!",
            "message": "Unfortunately, there was a problem updating the record.",
            closeCallback: function() {
                alert('You closed the alert!');
            }
        });
    }
})

Let me know if this helps

Thanks, 
Anudeep

 
Maharajan CMaharajan C
HI Neetu,

Please try with aura:doneRendering to close the modal instead of  trying in Init.

In CMP:
<aura:handler event="aura:doneRendering" action="{!c.doneRendering}"/>

In JS:
    doneRendering: function(cmp, event, helper) {
        $A.get("e.force:closeQuickAction").fire();
    }


Thanks,
Maharajan.C