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

ramilo
Kilo Contributor

Hi Valor,



I placed this code under a BR in the incident table. Take note that this is the only code of the BR.


When I tried this, the workflow seemed to get stuck in the Begin activity. Any idea why?



Thank you.



find_real_file.png


My code there was really old; but regardless, there may be an issue with the app reading the WF Transition history.



Of course, it's always better to use the OOB-provided methods to restart a workflow. In your case, it should work because it appears you only have one WF running, and no approvals.



You should be able to use this:


new Workflow().restartWorkflow(current);


Hey Valor,



We're trying to get this code to run but it doesn't appear to be working for us. Any clarification on the following block of code? I can't find any documentation on it.



 


  wf._deleteExecutingActivities(gr.sys_id + '');  


                wf._updateHistoryActivities(gr.sys_id + '');  


                wf._createBeginActivity(gr);  



My code is really old and is using undocumented, private methods.



I pilled those "_" methods out of the "Workflow" Script Include. As they're private, you'll not find any official documentation on it.



What at version are you running?


Yeah I noticed the date and was worried it might not work for us. We're running on Helsinki. I'll check out that script include and see if it explains why this isn't operating.



EDIT: I should have looked before replying it seems like the functions you're calling are not in the Workflow Script include. I'm going to assume they were stripped in later versions. Any suggestions to update this code for Helsinki?