CMP:
<aura:component implements="force:lightningQuickActionWithoutHeader,force:hasRecordId" controller="InvoiceIssueController" access="global">
<aura:html tag="style">
.slds-modal__container{
height : auto; width: 80%; max-width: 70vh;
}
.modal-body{
height : 15vh !important;
max-height: 15vh !important;
}
.slds-modal__footer{
display: inline !important;
}
</aura:html>
<aura:handler name="init" value="{!this}" action="{!c.callServer}"/>
<aura:handler event="force:refreshView" action="{!c.isRefreshed}" />
<aura:attribute name="showErrors" type="String"/>
<aura:attribute name="errorMessage" type="String"/>
<aura:attribute name="message" type="String"/>
{!v.message}
<aura:if isTrue="{!v.showErrors}">
<div class="slds-notify slds-notify_toast slds-theme_error">
<span class="slds-assistive-text">error</span>
<div class="slds-notify__content">
<p class="slds-align_absolute-center">{!v.errorMessage}</p>
</div>
</div>
</aura:if>
</aura:component>
JS:
({
callServer : function(component,event, helper) {
var myAttribute = component.get("v.recordId");
var action = component.get("c.ApexMethod1");
action.setParams({ "id" : myAttribute });
var action2 = component.get("c.ApexMethod2");
action2.setParams({ "id" : myAttribute });
action2.setCallback(this, function(response) {
console.log(response.getState());
if (response.getState() === "SUCCESS") {
$A.get('e.force:refreshView').fire();
}else {
console.log("Error Saving Contact ");
}
});
action.setCallback(this, function(response) {
if (response.getState() === "SUCCESS") {
if (response.getReturnValue() == 1) {
component.set("v.showErrors",true);
component.set("v.errorMessage","error!");
} else {
component.set("v.message","process...");
$A.enqueueAction(action2);
}
}else {
component.set("v.showErrors",true);
component.set("v.errorMessage","error");
}
});
$A.enqueueAction(action);
},
isRefreshed: function(component, event, helper) {
location.reload();
}
})
Apex:
Add @AuraEnabled to target ApexMethod