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
Shubham Sinha 56Shubham Sinha 56 

Popup alert through Visualforce Page.

Hi,
I have developed a Vf page in which I am showing an alert when a lead status is changed to 'Working'. It is working fine but everytime I open that record I see the alert but my requirement is to show only for once when a status is changed to working. How to do that.
 
<apex:page standardController="Lead" lightningStylesheets="true" rendered="{!Lead.Status ='Working'}">
<script type ="text/javascript">
{
window.alert("Your lead is now in ‘Working’ status. You have 5 business days to progress");
}
</script>
</apex:page>

 
ShivankurShivankur (Salesforce Developers) 
Hi Shubham,

It looks like the VF page is working as designed or intended,but when it comes to rerendering it based on previous value, we may need to take help of Apex and check if the value was actually changed on re-render and based on it the alert can be shown or similar logic can be tried to attempt. If the previous values of status field is same is the current then the alert should not be shown as required.

Similar attempts have been already discussed over below threads, if you wish to check with alternatives by the community members:
https://developer.salesforce.com/forums/?id=9060G000000BfTQQA0
https://developer.salesforce.com/forums/?id=9060G000000MUyKQAW
http://pranavmarathe.blogspot.com/2011/06/simple-pop-up-alert-in-salesforce.html

Hope above information helps. Please mark as Best Answer so that it can help others in future.

Thanks.
Suraj Tripathi 47Suraj Tripathi 47

Hi Subham,

Please try the below code.

<apex:page  standardController="Lead" lightningStylesheets="true" rendered="{!Lead.Status ='Working'}" >
<script type="text/javascript">
var a = '{!Lead.Status}';
var flag=true;
if(a == 'Working' && flag==true){
    window.alert("Your lead is now in ‘Working’ status. You have 5 business days to progress");
flag=false;
}
</script>
</apex:page>
Arlinda Fasliu 10Arlinda Fasliu 10
Hi Subham, Just following up, did the above code update work for you?