You need to sign in to do that
Don't have an account?
Sagar Bhatia
Can anyone explain how ProcessInstance and StepsAndWorkitems works for an approval process?
Hi ALL,
We are trying to access Approval/Rejection comments of the Approval process so that we can make sure the Approver / Rejector add there comments for every step. To do so we found we can access comments using nested query to ProcessInstance along with StepsAndWorkItems , although we are still trying to figure out how exactly StepsAndWorkItems relate with respect to each step in the Approval process.
When trying to query : SELECT Id, (SELECT Id,ProcessNodeId,ProcessInstanceId,Comments,TargetObjectId FROM StepsAndWorkitems )
FROM ProcessInstance
We could see multiple processNode for one Step, Really confused looking at the data .
We are trying to access Approval/Rejection comments of the Approval process so that we can make sure the Approver / Rejector add there comments for every step. To do so we found we can access comments using nested query to ProcessInstance along with StepsAndWorkItems , although we are still trying to figure out how exactly StepsAndWorkItems relate with respect to each step in the Approval process.
When trying to query : SELECT Id, (SELECT Id,ProcessNodeId,ProcessInstanceId,Comments,TargetObjectId FROM StepsAndWorkitems )
FROM ProcessInstance
We could see multiple processNode for one Step, Really confused looking at the data .
ProcessInstanceHistory object shows all steps and pending approval requests associated with a ProcessInstance.
ProcessInstanceHistory is created every time when record is submitted for approval, reassigned, approved or rejected.
StepsAndWorkItems is the child relationship name for ProcessInstanceHistory under the ProcessInstance object.
Thats why you have accessed comments using nested query to ProcessInstance along with StepsAndWorkItems.
Hope it clarify your query. Let me know if any confusion.
All Answers
ProcessInstanceHistory object shows all steps and pending approval requests associated with a ProcessInstance.
ProcessInstanceHistory is created every time when record is submitted for approval, reassigned, approved or rejected.
StepsAndWorkItems is the child relationship name for ProcessInstanceHistory under the ProcessInstance object.
Thats why you have accessed comments using nested query to ProcessInstance along with StepsAndWorkItems.
Hope it clarify your query. Let me know if any confusion.
That was very precise expaination , and well received ;)
Well there is one thing as mentioned above is the main situation we are stuck in i.e We are looking to block the Approver/ Rejector when comments field is left blank for each step in the approval process.
Is there any way we can validate the Comments fields for Null before saving the Approval/Rejection action ?
Thanks
User will approve, reassign or reject from the visuslforce page where we implement the approval logic in Apex code.
In standard way I found bellow blog post. Have a look if it work
http://christopheralunlewis.blogspot.in/2012/10/making-all-approval-comments-mandatory.html
Anyways thanks for the help :)
Regards,
Sagar