Restart a workflow context without affecting other workflows running on the record

pravTel
Kilo Contributor

Hello there,

I have a requirement to selectively restart a workflow context associated to an Incident record. This can be done by either restarting the workflow context or even by deleting & creating the workflow again.

I can see from wiki and forums about methods such as restartWorkflow(), deleteWorkflow() which acts on all workflows associated to that incident record. However, there are few other workflows (unrelated to the workflow version being restarted) on this record, which should not be affected by this restart.

Can anyone please guide me on the ways to restart a workflow context without affecting other workflows?

Regards,
Praveen

11 REPLIES 11

Jon_Jennings
Tera Contributor

Thanks for the code posting. It's working well for me.

I did run into an interesting issue when testing this - one of the steps in the workflow that I'm restarting is an approval activity. I had thought that each time through the workflow, a new approval would be created. Instead, the same approval is reset back to "requested" on each run-through of the workflow.

I'm exploring options but, in the meantime, this code really helped. Thanks again.


Look at the WorkflowApprovalUtils.

Something like:


new WorkflowApprovalUtils().reset(current, "Resetting approval based on workflow restart");