Is there a way to update workflow context which is already attached in change
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 03:47 AM
Hi All,
is there a way to update workflow context which is attached in change request.
There is a change request which is already opend and we have modified the normal change request workflow. is there a way to update already attached workflow with new chages(approval matrix)
Please suggest
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-21-2016 04:00 AM
I think you may need to use a script and call these utilities to either cancel or delete the existing workflow context and then restart a fresh workflow using the updated version:
Workflow Script - ServiceNow Wiki
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-29-2018 11:00 PM
Workflow context is a running instance of the workflow, I have not been able to replace an existing context that ran/waiting to run/running currently.
But you can cancel the existing context and start a new workflow context.
Did you get the answer for this? I resolved this issue by canceling the workflow context running and starting a new workflow.
You want to identify the context by querying the wf_context table and identify the specific workflow context that's related to your task/extended/custom table record.
Use the workflow script include library
to cancel the workflow by
Cancel the specific running workflow context and all subflows This is the normal, acceptable way to cancel a workflow that is in a wait state.
* @param context
* GlideRecord on table wf_context of the context to cancel
context - glide record for workflow context that you want to cancel
var oWorkflow = new global.Workflow;
oWorkflow.cancelContext(context);
oWorkflow.broadcastKill(context);
* Broadcast the Kill command to all nodes on an instance. Use this to Kill a workflow that is not responding. This will not
* affect a workflow that is in a wait state. Use cancel(...) to stop a workflow in a wait state.
* @param context
* GlideRecord on table wf_context of the context to kill
Now that you canceled the workflow context start the workflow
var newcontext = oWorkflow.startFlow(<workflowId:string>, <Glide Record of the task e.g. _change>, _change.operation(),{});
We are all borgs with the collective conscience knowledge of those came before us and passed on to us. Sharing is caring so share!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-09-2018 12:27 PM
I have not tested but you could look into
restartWorkflow(GlideRecord current, Boolean maintainStateFlag)
More info: Workflow api: https://developer.servicenow.com/app.do#!/api_doc?v=kingston&id=c_WorkflowAPI