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
Dorian S 5Dorian S 5 

rollup trigger salesforce

Hi there! I'm tryi'n to create rollup trigger by aggregate sum of fields

i have 2 custom objects with lookup field School__c on Classroom__c(child) ,objects:

-School__c with fields,Number_of_students__c,Name

-Classroom__c with fields,Students_Quantity__c,Name and lookup field School__c

How can i have a trigger(before insert,after update,before delete)?

thanks for all advices! 

 

Richard Fiekowsky 3Richard Fiekowsky 3
When a rollup field reaches a specific value, that cannot cause actual triggers to run - only inserts, updates, and deletes, which will always fire the associated trigger if there is one. You can write the trigger so that it does nothing, or it does the processing, after checking the value of the rollup field. Or, you can create a Flow which checks the values in its entry conditions. Either way, only a save (or delete, for triggers) will initiate the processing, which means that it probably must be based on the child object. (As a practical matter, governor limits prevent significant processing during triggers and flows, so writing schedulable batch classes is often the only solution.) 
 
Harshith KulalHarshith Kulal
Yes there are mutiple ways to do that IPO GMP (https://stockipo.in/ipo-gmp-grey-market-premium/) is also one where stockipo gmp you will get