You need to sign in to do that
Don't have an account?
Can you run a trigger off of ProcessInstance?
Hi,
I am trying to build a trigger that runs directly after a Salesforce approval process is submitted. Basically, I am trying to copy the approval information into a separate custom object that will create records that have both the approval information (Approver Name, Approval Status, etc.) and my custom object record information. This will allow me to run more relevant reports off of the approval instances (than available through [out of the box reports](https://docs.releasenotes.salesforce.com/en-us/summer14/release-notes/rn_forcecom_process_approval_history_reports.htm)). I also need the ability to generate a document with the approval information on it (who approved and when) and I can't find a solution for that without creating records in another object with the approval information copied into it.
I have attempted to run the trigger off of my custom object, but it seems impossible for the trigger to be able to run every time I need it to. For instance, if there are multiple approvers in a step, there doesn't seem to be a way to update a field on the custom object record until the step is over.
My question is if there is a way to run triggers off of ProcessInstance records (and subsequently ProcessInstanceStep and ProcessInstanceNode records). I can't seem to create a trigger using the ProcessInstance object.
Thanks,Matt
Yeah we can write logic for every object that is using approval process
Here is a link to another question I have asked regarding this issue if you want to look at the trigger so far: https://developer.salesforce.com/forums/ForumsMain?id=906F0000000kAFNIA2
If we take a custom status field in the object and update that field whenever the record is approved.
In trigger check the value of the field and compate to the old value if(new value = approved and Old vlaue!=approved) then do your logic