You need to sign in to do that
Don't have an account?

Using Approval process in Trigger
Hi,
I have a requirement where I need to add validation rule(saying that a field is blank), but that validation should fire if in approval process the stage gets to in review/ or the approver is the Queue of the assigned approver.
I tried using validation rule, but it seems it is not achievable via validation rule.
It seems I need to write a trigger and use StepsAndWorkitems to get the actorId.
Can someone please guide me on how to achive this requirement?
I have a requirement where I need to add validation rule(saying that a field is blank), but that validation should fire if in approval process the stage gets to in review/ or the approver is the Queue of the assigned approver.
I tried using validation rule, but it seems it is not achievable via validation rule.
It seems I need to write a trigger and use StepsAndWorkitems to get the actorId.
Can someone please guide me on how to achive this requirement?
This is the trigger that creates approval process on account object
I couldn't understand your last statement, by the way that can be handled by changing the codes in approval.processworkitemrequest req2.
Also before creating this class ,you have to setup approvalprocess on the object and use the same name in
req1.setProcessDefinitionNameOrId('ApprovalForAccount');
Go through this for setting up a approval creation
https://help.salesforce.com/articleView?id=approvals_creating_approval_processes.htm&language=en&type=0
Let me know if you need further help
Thanks and Regards,
Shiva RV
Currently I have a custom object Requirement__c which is using the standard approval process..
Now the change that needs to be implemented is, I need to add three new picklist fields (which i have added).
Requiremnet is not everyone should get validation error while updating/creating a Requirement.But before the approval process changes the stage to implemented, business needs that the three fields shouldnever be kept black, so they came up with having a rule so that when in approval process stage is in development, then they should get error while approving the approval, so that at that point development team should fill those fields.
I tried using validation rule, but seems validation rule cannot be applied for the standard approval process.