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

Trigger to update the picklist

Need help to write a trigger based on the following 


Trigger which will work on opptylineitem insert/delete which will compare the lowest threshold(currency field on Product) from all the products with the total oppty amount. If total oppty amount is greater than or equal to the lowest threshold on any of the products attached then populate the picklist field say ("Does oppty amount exceeds threshold") on custom object record linked to oppty to Yes.





If I am understanding this correctly, I'm not sure you need a Trigger.  You could probably do this with workflow field updates and rollup summaries.  In my experience, you should leverage the platform as much as possible before writing code.  Would this work?


1) Create workflow field update to populate a custom currency field on OpportunityProduct with the "threshold" currency field you mentioned from Product.  The reason why you need to do this and not a formula field is because you cannot reference a formula field in a rollup summary (step 2).


2) Create a rollup summary field on opporuntiy to check the value of that custom field.  The rest should just be formulas.


Does that help and fit your use case? 




I too agree with you.


But I need to write a trigger because the Threshold Currency field is updated through Data load once .



any idea for my Trigger.