0

Can anyone tell me how to write the trigger based on the approved records?
My use case is
I want to enter the records to queue if the record is approved by appropriate user.
I need an idea for this use case

Updated
Get the (custom object) record details in visualforce page and submit for the manager approval.
once he approved then the record should be submitted to the queue.
My question s how to write the trigger based on the approvals(Approved,reject and pending)
In which obj approvals are stored..

Thanks in advance
​Karthick

  • Can you please explain with more details/scenario? – Vignex Dec 11 '14 at 6:18
  • @Vignex: please check my question now – user3332076 Dec 11 '14 at 7:18
  • @Karthik, Please check my answer below! – Vignex Dec 11 '14 at 8:44
3

Approvals are handled in ProcessInstance object. For each and every update of your record in the approval process will have an entry (record) in this object. But you cannot write a trigger on this ProcessInstance object.

Instead please follow the below steps.

1) Create a picklist field - 'Approval Status' (Approval_Status__c) in your object with the values Pending,Approved and Rejected.

2) Configure your approval process: In the initial submission action, create a field update on the Approval_Status__c field to set the picklist value as Pending.

3) In the final Approval action section, create a field update on Approval Status field to set the value to Approved.

4) In the final Rejection action section, create a field update on Approval Status field to set the value to Rejected.

5) Now write the Before Update trigger on your object and check the value of Approval_Status__c. Based on the condition of the Approval_Status__c field , write your logic in the trigger to assign the record to the Queue.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.