You need to sign in to do that
Don't have an account?
Neetu 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-
({
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-
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
Let me know if this helps
Thanks,
Anudeep
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