-
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

5 Mistakes You Should Avoid While Hiring a Salesforce Implementation Consultant
If you need to start a Salesforce Implementation right from scratch, then you may require a trusted Salesforce Implementation Consultant with the right expertise and experience.…

Boosting Legal Firm Efficiency with Salesforce Management Solutions
The legal industry is constantly evolving, with firms facing challenges related to data management, client communications, case tracking, and regulatory compliance. Salesforce Management Solutions offer…
Popular Salesforce Videos
Salesforce Stock Pops on Better-than-expected Earnings and Guidance
Salesforce shares rose as much as 3% in extended trading on Wednesday after the enterprise software maker reported fiscal second-quarter earnings and forward guidance that…
Power of Personal Brand | The Shrey Sharma Show | Salesforce
Shrey is a Chief Executive Officer at Cyntexa, a SILVER Salesforce Consulting Partner in the USA, UK, UAE, Australia, Singapore & India, having a vibrant…
Should You Learn Salesforce in 2020?
The Salesforce industry has been the best-kept secret of our careers with average salaries near $150,000 - but is it still a good technology to…
Popular Salesforce Infographics

How Can You Become a Salesforce Admin?
Sometimes a piece of technology seems to be used at every company. Knowing how to use that technology can help a person’s career. It can…

Salesforce Marketing Cloud
Salesforce Marketing Cloud is a platform where relevant and personalized journeys are delivered across different devices and channels. This allows the marketers to deliver right…

Salesforce: Giving Buzz In Numbers
Salesforce has been coined as the world’s top CRM and there is always a constant buzz around it’s latest developments. So let’s check out what…