I have done lots of investigation and tried a few things but I am unable to get them to work and was hoping for some input.
I have tried this that I found here:https://jayakrishnasfdc.wordpress.com/2021/04/17/recall-an-approval-process-step-using-apex-or-lightning-flow-in-salesforce/
Recall Approval Process/Record Using Lightning Flow
Use a Screen Flow calling Apex Class to Update the Process Instance.
We cannot achieve this with only flow why Because ‘ProcessWorkitemRequest’ is not available in flow.
Created apex for this scenario
global class approvalRecall
{
@InvocableMethod
webservice static void recallApproval(List<Id> recId)
{
List<ProcessInstanceWorkitem> piwi = [SELECT Id, ProcessInstanceId, ProcessInstance.TargetObjectId FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId =: recId];
Approval.ProcessWorkitemRequest req = new Approval.ProcessWorkitemRequest();
req.setAction('Removed');
req.setWorkitemId(piwi.get(0).Id);
Approval.process(req,false);
}
}
I am using @InvocableMethod to display this method in flow. and Update to List for Id parameter.
Lets Create now the Flow.
I then created a Lightning action on the quote object to call the flow.
When run (normally or debug mode), this keeps returning a message that says zero values are being returned.
In workbench when I use the query SELECT Id, ProcessInstanceId, ProcessInstance.TargetObjectId FROM ProcessInstanceWorkitem WHERE ProcessInstance.TargetObjectId = Item in approval ID, I get no results which is obviosuly why it is breaking. This leads me to believe that the query being used to get the approval is incorrect. I have tried it on an item that has yet to be approved and one that has been approved and I get the same results, zero value.
Can ideas about how I can get this right without CPQ (which I know allows this function?
1 answer
Hi Lisa,
Sorry for the inconvenience. In case you don't receive a response here, may I also suggest joining the group below to collaborate with the experts for best practice and advice.
https://developer.salesforce.com/forums#!/feedtype=RECENT&criteria=ALLQUESTIONS&
Hope this helps.
Regards,
#.redirect