Opportunity object having one Account field Scinario: if Account field /= empty and stageName = closed won then only sys admin edit the record and not the other useres
You mean if Account field is null and opportunity is closed won only system admina can edit it. If any other users tries it should throw error? Yes, I know this happens in validation rule so I want to do this in trigger as well ?
Can you try the below trigger on Opportunity.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,
All Answers
You can set up a validation rules checking the conditions that you mentioned, which allows only the System Administrator to edit th record.
Thanks,
KP
You mean if Account field is null and opportunity is closed won only system admina can edit it. If any other users tries it should throw error?
Can you clarify on it so can prepare the vallidation rule and share the same
Thansk,
Yes, I know this happens in validation rule so I want to do this in trigger as well ?
Can you try the below trigger on Opportunity.
Let me know if you face any issues.
If this solution helps, Please mark it as best answer.
Thanks,