-
Popup on change of status to not booked on opportunity page.
<aura:component implements="flexipage:<wbr>availableForRecordHome,force:<wbr>hasRecordId,force:<wbr>lightningQuickActionwithouthea<wbr>der" access="global" > <aura:attribute name="opportunityRecord" type="Opportunity"/> <aura:attribute name="recordError" type="String"/> <aura:attribute name="showPopup" type="Boolean" default="false" /> <force:recordData aura:id="opportunityRecordCmp" recordId="{!v.recordId}" fields="Id,StageName,<wbr>ForecastCategoryName, LeadSource,<wbr>DeliveryInstallationStatus__c,<wbr>Description" targetFields="{!v.<wbr>opportunityRecord}" recordUpdated="{!c.showPopup}" targetError="{!v.recordError}" mode ="EDIT"/> <!-- Here we wrapped our modal code inside aura:if. If it evaluates true, code inside it will be visible --> <aura:if isTrue="{!v.showPopup}" > <div class="demo-only" style="height: 100px;"> <section role="dialog" tabindex="-1" aria-labelledby="modal-<wbr>heading-01" aria-modal="true" aria-describedby="modal-<wbr>content-id-1" class="slds-modal slds-fade-in-open"> <div class="slds-modal__container"> <!-- Header of Modal --> <!-- Body of Modal --> <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1"> <!-- Display an editing form --> <div class="Record Details"> <lightning:card title="close Opportunity"> <div class="slds-p-horizontal--<wbr>small"> <lightning:input label="LeadSource" value="{!v.opportunityRecord.<wbr>LeadSource}"/> <lightning:select name="<wbr>DeliveryInstallationStatus__c" label="<wbr>DeliveryInstallationStatus" value="{!v.opportunityRecord.<wbr>DeliveryInstallationStatus__c}<wbr>"> <option value="">choose one...</option> <option value="In progress">In progress</option> <option value="Yet to begin">Yet to begin</option> <option value="Completed">Completed</<wbr>option> </lightning:select> <lightning:input type="string" name="Description" label="Description" value="{!v.opportunityRecord.<wbr>Description}"/> </div> </lightning:card> </div> </div> <!-- Footer of Modal --> <footer class="slds-modal__footer"> <lightning:button variant="brand" label="OK" title="Save" onclick="{!c.<wbr>handleSaveCampaign}" /> <lightning:button variant="brand" label="Cancel" title="Cancel" onclick="{! c.handleCancel }" /> </footer> </div> </section> <!-- Backdrop to set background slightly opaque. --> <div class="slds-backdrop slds-backdrop_open"></div> </div> </aura:if> <!--End of Modal Footer--> <!-- Display Lightning Data Service errors, if any --> <aura:if isTrue="{!not(empty(v.<wbr>recordError))}"> <div class="recordError"> <ui:message title="Error" severity="error" closable="true"> {!v.recordError} </ui:message> </div> </aura:if> </aura:component>
==============================<wbr>======================
controller.js code:
({ showPopup:function(component, event, helper) { var changeType = event.getParams().changeType; if (changeType === "CHANGED" && (('StageName' in event.getParams().<wbr>changedFields))) { var newStageName = event.getParams().<wbr>changedFields.StageName.value; var oldStageName = event.getParams().<wbr>changedFields.StageName.<wbr>oldValue; if((newStageName == 'Closed Lost') && newStageName != oldStageName){ component.set('v.showPopup',<wbr>true); } } }, handleOk:function(component, event, helper) { component.set('v.showPopup',<wbr>false); }, handleCancel : function(component, event, helper) { component.set('v.showPopup',<wbr>false); }, handleSaveCampaign: function(component, event, helper) { component.find("<wbr>opportunityRecordCmp").<wbr>saveRecord(function(<wbr>saveResult) { if (saveResult.state === "SUCCESS" || saveResult.state === "DRAFT") { // record is saved successfully var resultsToast = $A.get("e.force:showToast"); resultsToast.setParams({ "title": "Saved", "message": "The record was saved." }); resultsToast.fire(); } else if (saveResult.state === "INCOMPLETE") { // handle the incomplete state console.log("User is offline, device doesn't support drafts."); } else if (saveResult.state === "ERROR") { // handle the error state console.log('Problem saving campaign, error: ' + JSON.stringify(saveResult.<wbr>error)); } else { console.log('Unknown problem, state: ' + saveResult.state + ', error: ' + JSON.stringify(saveResult.<wbr>error)); } component.set('v.showPopup',<wbr>false); }); } })
Log In to reply.
Popular Salesforce Blogs

B2B Ecommerce: How to Take Your B2B Shop Online and Grow Your Business (Examples of Salesforce Automation Inside)
After COVID, it seems even pointless to explain why taking your business online is a necessity if you want to grow your sales. However, there's…

CRM for FinTech: Why Choose Salesforce For Fintech Companies?
Recently German specialists of information technologies published the article “What determines FinTech success?—A taxonomy-based analysis of FinTech success factors”. They provided insights into the potential determinants…

Learn All About Flows in Salesforce and Its Powers
What is a Flow in Salesforce? In Salesforce, a flow is an application that computes complex business measures. Basically, it gathers information and afterwards accomplishes…
Popular Salesforce Videos
LWC Interview Questions -1 ( Freshers)
In this video, Kumar Salesforce provides a list of LWC Interview Questions that may be helpful for those who are just starting out. Watch this…
Salesforce Partner Program 2020: Everything You Need to Know!
Embarking on this new program year, PY21, Salesforce will be implementing some enhancements to its Partner program to ensure the central focus on customer success…
Popular Salesforce Infographics

Salesforce: A Powering Business Of All Sizes
Salesforce is a cloud-based software that helps businesses track and manage their interactions with customers and potential customers. More than 150,000 companies worldwide use Salesforce.…

The ROI of Building Apps on Salesforce
With our ROI Calculator, embark on a journey to discover how much more productive your organization can be when building apps using the Salesforce Platform.…

How Can Your Company Benefit from Salesforce Community Cloud
Salesforce Community Cloud is an online platform where companies can connect customers, partners, and employees with each other and the data or records they need…