function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
rahul Shukla 37rahul Shukla 37 

Pop up alert while changing opportunity stage

Hi Everyone,
Please help me to achieve scenario 
when i will change the opportunity stage to confirm then i need one pop up the will show 2 button confirm and cancel.

 
SwethaSwetha (Salesforce Developers) 
HI Rahul,
You can go with an app exchange package: https://appexchange.salesforce.com/appxListingDetail?listingId=a0N3A00000FYDyHUAX

If it is in lightning, you can try the approach suggested in https://salesforce.stackexchange.com/questions/317205/lightning-pop-up-on-opportunity-stage-change
WarningModal.cmp
<aura:component implements="flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickActionwithoutheader" access="global" >
<aura:attribute name="opportunityRecord" type="Opportunity"/>
<aura:attribute name="recordError" type="String"/>
 <aura:attribute name="openModal" type="Boolean" default="false" />

      <force:recordData aura:id="opportunityRecordCmp"
                      recordId="{!v.recordId}"
                      fields="Id,StageName"
                      targetFields="{!v.opportunityRecord}"
                      recordUpdated="{!c.openModal}"
                      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.openModal}" >
        <div class="demo-only" style="height: 100px;">
            <section role="dialog" tabindex="-1" aria-labelledby="modal-heading-01" aria-modal="true" aria-describedby="modal-content-id-1" class="slds-modal slds-fade-in-open">
                <div class="slds-modal__container">
                    <!-- Header of Modal -->
                    <header class="slds-modal__header">
                        <lightning:buttonIcon iconName="utility:close" class="slds-modal__close" size="small" variant="bare" alternativeText="Close" onclick="{! c.closeModal }"/>
                        <h2 id="modal-heading-01" class="slds-text-heading_medium slds-hyphenate">Warning</h2>
                    </header>
                     <!-- Body of Modal -->
                    <div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
                        <p> Closed Won Opps are not recovered. Continue?</p>
                    </div>
                    <!-- Footer of Modal -->
                    <footer class="slds-modal__footer">
                        <lightning:button variant="brand" label="OK" title="Save" onclick="{!c.handleOk}" />
                        <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.recordError))}">
        <div class="recordError">
            <ui:message title="Error" severity="error" closable="true">
                {!v.recordError}
            </ui:message>
        </div>
    </aura:if>
</aura:component>
WarningModal.js
({
   
openModal:function(component, event, helper) {
    var changeType = event.getParams().changeType;
    
    if (changeType === "CHANGED" && (('StageName' in event.getParams().changedFields))) {
        var newStageName = event.getParams().changedFields.StageName.value;
        var oldStageName = event.getParams().changedFields.StageName.oldValue;
        if(newStageName == 'Unqualified' && oldStageName == 'Closed Won'){
            component.set('v.openModal',true);
        }
    }
},
             
 handleOk:function(component, event, helper) {
      
        component.set('v.openModal',false);

     },
    
    handleCancel : function(component, event, helper) {
        component.set('v.openModal',false);
    }
})
Related: In classic: https://developer.salesforce.com/forums/?id=906F000000097LbIAI
https://trailblazers.salesforce.com/answers?id=9063A000000E3lPQAS

Hope this helps you. Please mark this answer as best so that others facing the same issue will find this information useful. Thank you
 
RituSharmaRituSharma
User can change statge using multiple ways:
1. Using standard page layout (classic/lightning)
2. List View
3. Kanban view
4. Custom page

As per current design, what all options are available for the user?
rahul Shukla 37rahul Shukla 37
Ive tried your updated code and the pop up seems to be working now upon Stage change!!! However, upon move from Closed Won to Unqualified, the pop up does show up but, the record is being saved to Unqualified before hitting Ok or cancel buttons on the Pop up. Do you know how I can prevent the default save from happening upon Stage change? 
 the current record should only be saved onclick of OK button and should not save changes on click of Cancel button. Meaning, onCancel, the record should revert to the previous Stagename of Closed Won. –