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
chirugantachiruganta 

How to block account territory from change when it have closed opportunity?

Hi, I have a requirement that when an opportunity is in Closed won satge the territory of that account need to be restrictd ()? Is it possible to restrict using trigger? If yes, please help me.
Satish_SFDCSatish_SFDC
Yes. You can use a before update trigger on Opportunity
You will have Trigger.old and Trigger.new variables in the before update trigger.
Compare the values of the old opportunity and new opportunity and throw an error if the values do not match and the opportunity is closed won.

Regards,
Satish Kumar
chirugantachiruganta
Hi Stish, thanks for the reply. I need to restrict the account territories value. For example I have a territory "Test territory" and have account in the territory. I need to restrct the user to not to change that Territory.
Satish_SFDCSatish_SFDC
There might be multiple opportunities for a single account. Do you want to restrict territory change even if a single opportunity under that account is closed won.

Regards,
Satish Kumar
chirugantachiruganta
Yes Satish.