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
SalesIntelSalesIntel 

Help with limiting pop-up messages

The following code creates a pop up message each time a support engineer accesses a Case record. My issue is that the pop-up message displays each time a support engineer changes screen within the same case. Can you tell me how I would modify the code to display the pop up message only once? In other words, only the first time the Case record is accessed?

 

<html> 
<head> 
<script type="text/javascript"> 
var s = ""; 
function checkAlert() 
{ 
// Look for account message 
try { 
a = "{!JSENCODE(Account.rrpu__Alert_Message__c)}"; 
if (a.length > 0) { 
s += "Account Alert: " + a + "\n"; 
} 
} 
catch(err) { } 

// Look for contact message 
try { 
c = "{!JSENCODE(Contact.rrpu__Alert_Message__c)}"; 
if (c.length > 0) { 
s += "Contact Alert: " + c + "\n"; 
} 
} 
catch(err) { } 

// Look for lead message 
try { 
l = "{!JSENCODE(Lead.rrpu__Alert_Message__c)}"; 
if (l.length > 0) { 
s += "Lead Alert: " + l + "\n"; 
} 
} 
catch(err) { } 

// Look for opportunity message 
try { 
o = "{!JSENCODE(Opportunity.rrpu__Alert_Message__c)}"; 
if (o.length > 0) { 
s += "Opportunity Alert: " + o + "\n"; 
} 
} 
catch(err) { } 

// Look for case message 
try { 
ca = "{!JSENCODE(Case.rrpu__Alert_Message__c)}"; 
if (ca.length > 0) { 
s += "Case Alert: " + ca + "\n"; 
} 
} 
catch(err) { } 

// Pop-up message if any alerts found 
if (s.length > 0) 
{ 
window.alert(s); 
} 
} 

</script> 
</head> 
<body onload="checkAlert()"> 
</body> 
</html>

 

 

bob_buzzardbob_buzzard

If you can only use javascript, you'll need to set a cookie on the users browser to indicate an alert has been shown for the case id.  If you can use visualforce, you could control this via a boolean property on the controller.  Initialise it to true in the constructor and after the alert invoke an actionfunction that sets it to false.