0

I have a use case where we want the Opportunity owner to be always owned by a Sales User, as sometimes a non-Sales users creates an opportunity & forgets to change the owner to Sales user as Sf doesn't allow user to change the owner while creating an opportunity. We also have Rollup summary fields on opportunity which rollsup from opportunityLineitems.

Currently, when an opportunity is inserted we have an automation on afterinsert to create an opportunitylineitem which then gets back onto the rollup summary field on opportunity causing the trigger to fire again.

Considering this I tried adding the custom apex validation rule on beforeupdate by bypassing the validation rule criteria on beforeupdate trigger caused due to rollup (by checking IF newrollUpvalue value != oldRollUpValue) so that the automated opplineitem gets created uninterrupted. However, I want the validation to happen moving forward - meaning any beforeupdate trigger that fires after the 1st trigger (which fired due to insert) must throw a validation solely based on the condition if Owner != A Sales user

Please let me know your thoughts on how to approach this. Really appreciate your help!

SMorse
  • 39
  • 13

1 Answers1

1

Sounds like you need a recursion blocker for your trigger handling. If not familiar with the concept - this knowledge article is a good start. (There are many approaches and opinions on offer out there.)

resedasue
  • 293
  • 1
  • 9