+ Start a Discussion
GMASJGMASJ 

alert message on standard page

Hi,

   In case object we have a picklist "type" I want to display a alert message when user selects picklist "Enhancement" or "Issue" as value please suggest me how to implement this on salesforce standard page. 

Thanks
Sudhir
Khan AnasKhan Anas (Salesforce Developers) 
Hi Sudhir,

Greetings to you!

You need to create a visualforce page to edit Case. Then, override standard Edit button with visualforce page.
I have implemented the same functionality on the Opportunity object.

Visualforce:
<apex:page standardController="Opportunity" extensions="OpportunityEditPageC" sidebar="false">
    <apex:form >
        
        <apex:outputPanel id="tstpopup">
            <apex:outputPanel styleClass="popupBackground" layout="block" rendered="{!displayPopUp}" />
            <apex:outputPanel styleClass="custPopup" layout="block" rendered="{!displayPopUp}" >
                <p> You have selected Warm Rating !!! </p>
                <apex:commandButton value="Ok" action="{!closePopup}" reRender="tstpopup" />
            </apex:outputPanel>
        </apex:outputPanel>
        
        <apex:pageBlock title="Opportunity Detail">
            <apex:pageBlockbuttons >
                <apex:commandButton value="Save" action="{!save}"/>
            </apex:pageBlockbuttons>
            <apex:pageBlockSection title="Opportunity Information 1" columns="2" collapsible="false">
                <apex:outputField value="{!accnt.OwnerId}" />
                <apex:inputField value="{!accnt.Name}"/>
                <apex:inputField value="{!accnt.Account.Name}"/>
                <apex:inputField value="{!accnt.DeliveryInstallationStatus__c}"/>
                <apex:inputField value="{!accnt.TrackingNumber__c}"/>
                <apex:inputField value="{!accnt.CloseDate}"/>
            </apex:pageBlockSection>
            <apex:pageBlockSection title="Opportunity Information 2" columns="2" collapsible="false">
                <apex:inputField value="{!accnt.Description}"/>
                <apex:inputField value="{!accnt.LeadSource}"/>
                <apex:inputField value="{!accnt.NextStep}"/>
                <apex:inputField value="{!accnt.Type}"/>
                
                <apex:inputField value="{!accnt.StageName}">
                    <apex:actionSupport action="{!showPopup}" event="onchange" reRender="tstpopup">
                        <apex:param name="accid" value="{!accnt.id}" assignTo="{!accid}"/>
                    </apex:actionSupport>
                </apex:inputField>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
    
    <style type="text/css">
        .custPopup{
        background-color: white;
        border-width: 2px;
        border-style: solid;
        z-index: 9999;
        left: 50%;
        padding:10px;
        position: absolute;
        width: 500px;
        margin-left: -250px;
        top:100px;
        }
        .popupBackground{
        background-color:black;
        opacity: 0.20;
        filter: alpha(opacity = 20);
        position: absolute;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        z-index: 9998;
        }
    </style>
</apex:page>

Controller:
public class OpportunityEditPageC {

    public Opportunity accnt {get;set;}
    public Boolean displayPopup {get; set;}
    public String accid {get;set;}
    public String oid;
    
    public OpportunityEditPageC(ApexPages.StandardController controller) {
        Opportunity temp = (Opportunity)controller.getRecord();
        oid = temp.Id;
        accnt = [SELECT Id, OwnerId, Name, StageName, Account.Name, DeliveryInstallationStatus__c, TrackingNumber__c, CloseDate, Description, LeadSource, NextStep, Type 
                 FROM Opportunity 
                 WHERE Id=:oid];
    }
    
    public void closePopup() {
        displayPopup = false;
    }
    
    public void showPopup() {
        //for(Opportunity ac : accnt) {
            if (accnt.Id == accid) {
                if(accnt.StageName=='Qualification'){
                    displayPopup = true;
                }
            }
        //}
    }
}

Override Standard Edit Button:
User-added image


Screenshot:
User-added image


User-added image



I hope it helps you.

Kindly let me know if it helps you and close your query by marking it as solved so that it can help others in the future. It will help to keep this community clean.

Thanks and Regards,
Khan Anas