-
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
Apex Test Class in Salesforce - Lear All About It
Introduction Apex testing framework enables you to write and execute tests for your apex classes and triggers on the lightning platform. Apex unit tests ensure…
What do you mean by Ant Migration in 2023? | Salesforce Developer Guide
Salesforce is a popular customer relationship management (CRM) platform used by businesses of all sizes to manage their sales, marketing, and customer service operations. One…
Creating and Populating a Wrapper in Apex
As Apex is a statically typed language, you must choose only one object type per list to iterate. What if you want to iterate an…
Popular Salesforce Videos
Salesforce Object Search Language: What is SOSL and when to use SOSL?
When to Use SOSL? Use SOSL when you don’t know which object or field the data resides in, and you want to: Retrieve data for…
What are APEX Environments? | Learn Salesforce Development
In this video, Shrey explained the Apex Environments. He covered answers for the following questions while explaining: What are the APEX Environments? Different types of…
Salesforce Customer 360 for B2C Solutions
Learn about Slalom's approach to creating integrated customer-focused experiences spanning B2C Commerce, Marketing Cloud, Service Cloud, Experience Cloud, and beyond. Watch this video by Salesforce…
Popular Salesforce Infographics
Salesforce Summer'20 Release - Infographic
Salesforce, the world’s # 1 CRM is always on the lookout to connect to its customers, partners, employees with innovative features all around the world,…
Salesforce Unveils Sales and Service Suites Aimed at Accelerating ROI for Businesses
Salesforce has recently unveiled fresh sets of product suites aimed at enhancing the sales and service teams' performance. By integrating top-notch solutions from the Customer…
How To Sell Better in 2020 | Tips From Salesforce Leaders
There are various things that you need to pay heed on while selling something. In 2020, where technology is ruling the world, and we are…