0

When a user edits the value of a custom field business_sector__c on Opportunity using a standard page in Classic UI and clicks 'Save', I want to pop up a message reminding them that they need to review a field value on Opportunity Products. The popup should just have an 'OK' button that closes it.

What is the recommended approach for this?

Thanks.

  • The popup is required when the field value is changed. The value that it is changed to does not matter. – MikeA Nov 17 '16 at 10:45
3

if you are cool with replacing the edit button functionality to a custom vf pgae then I think we can achieve this.

In below example, i have a field leadSource on opportunity. if someone clicks edit on an opportunity and changes value of leadSource, a pop up will come step1: create a page which uses standardController=opportunity.

VF PAGE:

<apex:page standardcontroller="opportunity" extensions="testEditOppController" standardStylesheets="true" sidebar="true" showHeader="true">
<apex:form>
    <apex:outputPanel id='testPanel'>
        <script>
        function funcTest(varA){
            if(varA){
                alert('LEAD SOURCE IS CHANGED');
            }
            redirectToDetailPage();
        }
        </script>
    </apex:outputPanel>
    <apex:actionFunction name="doSave" rerender="testPanel" action="{!test}" oncomplete="funcTest('{!isChanged}'); "/>
    <apex:actionFunction name="redirectToDetailPage" action="{!redirectMethod}"/>
    <apex:outputPanel layout="block">
        <apex:pageBlock>
            <apex:pageBlockSection columns="2" title="Opportunity Information" collapsible="false">
                <apex:inputField value="{!Opportunity.LeadSource  }" style="height: 20px"/>
                <apex:inputField value="{!Opportunity.closeDate}" style="height: 20px"/>
                <div  style="text-align:center;">   
                    <apex:commandButton onclick="doSave();" 
                                        oncomplete="funcTest()" value="Save"/>
                </div>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:outputPanel> 
</apex:form>

Controller:

public class testEditOppController {
@TestVisible private final opportunity opp;
    public ApexPages.StandardController stdCon;
    public boolean isChanged{get;set;}
    public string callfunc{get;set;}
    public opportunity currentOpp{get;set;}

    public testEditOppController(ApexPages.StandardController stdCon){
        this.opp=(opportunity)stdCon.getRecord();
        currentopp=[select leadSource from opportunity where id=:this.opp.id limit 1];
    }  
    public void test(){
        if(currentOpp.LeadSource!=this.opp.LeadSource){
            isChanged=true;
        }
        update this.opp;
    }
    public pagereference redirectMethod(){
        PageReference pageRef=new PageReference('/' + this.opp.id);
        return pageRef;
    }
}

On opportunity, for edit button, override with the visual force page you created above.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.