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
krishna guptakrishna gupta 

Update Approval process using triggers

Hi Guys,

I have a requirement for approval Process.
The record is assigned to the user,  i want to approve the record without clicking on Approve/Reject.
It means the status has to be changed from Pending to Approved.
Please let me know if anyone having idea.
Srinath T MenonSrinath T Menon
I am not very sure if I understand your requirement correctly. From what I can, I think the below would help:
  • Write a before update trigger on the object.
  • Compare ownerId fields to check if ownership has changed.
  • If yes, then query the designated approver user/store userid in custom setting and check if the new owner is the designated approver.
  • If yes, then change the status field as "Approved".
Let me know if this is not what you are looking for.

- Srinath