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
DSchild-PTECDSchild-PTEC 

Trigger to update checkbox when a formula field is updated

I have a formula field on my Opportunities that references a field on a related object. The formula field is called Assigned_Part_Number__c. Since any updates to the formula field do not create a change on the opportunity itself, the last modified date doesn't change, and therefore I cannot kick off a basic trigger.

 

What I figured I would do is write an APEX trigger that would search for Opportunities that have a value in my formula field and then update the opportunity by checking a box (a field called Send_Alert__c). 

 

This is my first apex trigger, and I'm already lost. 

Cool_DevloperCool_Devloper

Hi There,

 

What you can do is write a trigger on the related object, which is triggered whenever the record is updated for that specific field value which is used in the Formula Field.

 

Inside the same trigger, fetch all the related opportunities using a relationship query and update the checkbox field on them or you can directly process those records within this trigger itself!!

 

if you face any limitations then you can make some asynchronous calls to do the requisite processing...

 

Hope this helps!!

Cool_D