To recall a workflow through code you can use the cancelworkflow method in workflow class. It takes the correlationId and a comment as parameters and gets the job done for you. Example
workflow::cancelworkflow(CorrelationId, “Cancelling this workflow”)
Now you are probably thinking How do I find my workflows CorrelationId. You can do that by querying WorkflowTrackingStatusTable sorting it with time and instance number and joining it with SysWorkflowtable against the correlationId field and in the contextId you pass the RecId of your record for example PO RecId.
why we have to do joining with the table WorkflowTrackingStatusTable although correlationId can be retrieved directly from SysWorkflowtable using the field WorkflowCorrelationId and by filtering on ContextRecId & ContextTableId?
LikeLike
Hi what would be the code for cancelling a workflow with the same UserId as the Requester.?
LikeLike