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
Heather_HansonHeather_Hanson 

Create Popup alert on Account when Contact needs to be updated

I need to create a popup alert on Account object that is triggered when the related contacts (related list) need to be updated.  So I want to look at a custom date field in Contact "Last_Verified__c" and if it is blank or older than 2 years this should trigger the popup on the Account to recommend updating the contacts.

I can figure out the visualforce page, but I'm still new to Apex (I've only got about 3 triggers so far) and this one feels a little complicated.  Can anyone help get me started on the Apex Class?

Thanks!
Alain CabonAlain Cabon
Hi,

That is not possible from a trigger. A trigger can just stop the program with an error (addError Marks a trigger record with a custom error message and prevents any DML operation from occurring) but that is the only message allowed and that is not a popup either (but that suggests falsely that any "message" can be sent from a trigger).

It is a common need (many same questions about a popup and a trigger) but that cannot be done from a trigger. The popup must be triggered from a Visualforce page after the synchronous updates/inserts of records (including the synchronous triggers) by reading the value that you want to check. 
 
Mohan Reddy 80Mohan Reddy 80
Hi Alain,

Did you find any solution ?
Heather_HansonHeather_Hanson

Hi Mohan,

I didn't follow through with this exact plan, but did something similar.  I wanted to verify a specific field in the Contact record and if none of the contacts had a specific value I wanted a Rich Text notice to pop up on the Account Screen (I use Lightning). I ended up downloading Rollup Helper (https://appexchange.salesforce.com/appxListingDetail?listingId=a0N30000009i3UpEAI) from the App Exchange and with that I was able to create rollup fields for the Contact related list on the account in the background. Then I created a rich text component that showed up only when the rollup fields were providing a certain value.  

My example is this.  Each account should have at least 1 contact labellled MAIN, BILLING, and TECHNICAL.  So I have 3 rollup fields on the account.  One counts the contacts labelled as MAIN, and the other two count the contacts labelled BILLING and TECHNICAL. I then have a Rich Text component on the Account screen that appears on the condition that one of those rollup fields is 0, meaning they are missing one of the necessary contacts.

Anyway, Rollup Helper was really easy to download and use so I recommend it.  
 

Hope that helps!