", "answerCount": 5, "upvoteCount": 0, "datePublished": "2016-08-02T06:27:07.000Z", "author": { "@type": "Person", "name": "Usha Charles", "url": "https://trailblazers.salesforce.com/profileView?u=0053000000Azy6nAAB", "affiliation": { "@type": "Organization", "name": "--" } }, "acceptedAnswer": { "@type": "Answer", "text": "You may achieve this as below 1. Old Value :  Define a final variable in Apex Class to store Case Status   2. New Value : Passed as parameter to the JS function by the onchange Event   //APEX CLASS public final String CaseInitialStatus{get;set;} //CONSTRUCTOR objCase = (Case)controller.getRecord(); CaseInitialStatus = objCase.Status;    ", "upvoteCount": 1, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8ZtsSAF", "datePublished": "2016-08-02T11:59:46.000Z", "author": { "@type": "Person", "name": "Narendra Varma", "url": "https://trailblazers.salesforce.com/profileView?u=0053000000BLNMSAA5", "affiliation": { "@type": "Organization", "name": "--" } } }, "suggestedAnswer": [ { "@type": "Answer", "text": "    ", "upvoteCount": 0, "url": "https://trailhead.salesforce.com/trailblazer-community/feed/0D54S00000A8ZtsSAF", "datePublished": "2016-08-02T08:08:00.000Z", "author": { "@type": "Person", "name": "Naveen Dhanaraj", "url": "https://trailblazers.salesforce.com/profileView?u=0053000000CV5VnAAL", "affiliation": { "@type": "Organization", "name": "Aintiram Web Tech" } } } ] } } Skip to main content
Hello,

 

I have the created a visualforce page to display a pop up alert whan a case is closed. Now, I want this alret message to apprea only when a case is closed & not everytime a closed case is refreshed. So I must add a condition to say that the stage value != to old value.  Can someone please help ? 

 

 

<apex:page standardController="Case" showHeader="false" sidebar="false">

<script type="text/javascript">

if(

{!

AND(Case.Status = 'Closed'

)

}

)

{

alert('Please attach a Library Case.');

}

</script>

</apex:page>

 

 
5 respuestas
  1. 2 ago 2016, 11:59

    You may achieve this as below

    1. Old Value :  Define a final variable in Apex Class to store Case Status

     

    2. New Value : Passed as parameter to the JS function by the onchange Event

     

    <!-- JAVA SCRIPT-->

    <script type="text/javascript">

    function alertMessage(status){

    if(status != '{!CaseInitialStatus}' && status == 'Closed')

    {

    alert('Please attach a Library Case.');

    }

    }

    </script>

    <! -- Visualforce -->

    <apex:inputField value="{!Case.Status}" onchange="alertMessage(this.value);"/>

    //APEX CLASS

    public final String CaseInitialStatus{get;set;}

    //CONSTRUCTOR

    objCase = (Case)controller.getRecord();

    CaseInitialStatus = objCase.Status;

     

     
0/9000