The Now Platform® Washington DC release is live. Watch now!

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
joe_steinfeld
ServiceNow Employee
ServiceNow Employee

I am writing this article to show how a cancelled workflow can be resumed. This came about due to a customer where several workflows got cancelled due to a looping workflow that exceeded the "Max Activity Count" Workflow property.   The "Max Activity Count" workflow parameter is a fail safe on workflows preventing endlessly looping workflows from being a drain on a customer's instance. In this case, the "Max Activity Count" was set too low and thus we needed a way to resume the workflows from where they left off.

I wish I could say I was smart enough to have devised these procedures myself, but the true hero here was Sean Hamilton, from our support department, who showed me how to accomplish this.

The steps below show how to manually resume, but this process could be automated via a UI action if need be.   Perhaps, I will send out another post with an automated way of doing this.

1. Navigate to   "Workflow Context"   and find cancelled workflow you want to restart:

        workflowcontext_1.jpg

2. From there goto "Workflow Transition History" Tab and find the step you want to resume at (See Red 2 in screenshot below)

        (NOTE: This step will be run again)

3. You need to get the "sys_id" of this step by doing the following:

        - Click on the "From" Column to bring up "Workflow Activity" screen (See Red 3 in screenshot below)

Transition_History_2.jpg

4. From "Workflow Activity" Screen Right Click on header and select "Copy sys_id" from menu and copy and save that in notepad making sure to add label so you know what sys_id it is   (See Screenshot below)

      workflowactivity_3.jpg

5. Go back to "Workflow Context" record, by hitting back button on browser

6. Right Click on header and click on "Show XML" and search for "version" and not the workflow version sys_id and copy and paste that in notepad putting label by it so you know what sys_id it is.   (See Screenshot below)

ShowXML_4.jpg

7. Close "XML" window

8. Go to "Workflow Executing Activities" Tab and "Right Click" on one of the column headers (Ex. "Started") and select "Personalize -> List Control" and from List Control window "uncheck" the "Omit New Button" and then click "Update"     (See Screenshot below)

ListControl_5.jpg

9. You now have "New" Button on "Workflow Execuring Activities" Tab. (See Screenshot Below)

NewButton_6.jpg

10. Click on "New" Button and from the "Workflow Executing Activity" screen you will want to search for "Activity", but use filter and search using "Sys_id starts with <sys_id for workflow activity you looked up in step 4>"   and select resulting workflow activity   (See Screenshot below)

WorkflowContextSysID_7.jpg

11.   Do the same steps for "Workflow Version" field, but search for "sys_id starts with <sys_id of workflow version you saved in step 6.   (See screenshot below)

WorkflowVersionSysID_8.jpg

12. Click "Submit" to save the record and you should now have a record in the "Workflow Executing Activities" Tab (See Screenshot)

WFExecActivity_9.jpg

13. Set "State = Executing" and "Active" is checked.

14. To actually resume the workflow we now need update the "ID" field on the "Workflow context record". Do this by clicking on the "box" icon next to "ID" field and update label in some fashion and click "Update".   This will make the record dirty and cause the workflow to be processed.   (See Screenshot Below)

UpdateWFID_10.jpg

15.   Your Workflow should now continue executing and you can verify this by looking at "Transition History" tab or clicking on "Show Workflow" link

Comments
Inactive_Us2432
Kilo Contributor

Hi,



The 14 step, what label am i updating, my id field is Read Only but i do have the box on the right of the field that links to my RITM


Reyes
ServiceNow Employee
ServiceNow Employee

update a field on the RITM and what will resume the workflow


sohan_snow
Tera Contributor

Hi Reyes,



I tried creating the workflow   executing activity as mentioned in point 10, but was unable to do so as all the fields were greyed out on the form. Can you assist , why it ishappening





find_real_file.png



Thanks


Sohan Kumar


Reyes
ServiceNow Employee
ServiceNow Employee

sohan_snow,



Here are a few more steps that are needed to resume the workflow in Helsinki.



Step 10, when you click on the new button, the fields on this form is read-only, there is a UI policy you will need to disable (default read only)


Step 11, you will need to add the workflow version field on this form


Step 13, you will need to export XML of the wf_context record you are trying to resume, modify the XML file (state = executing, active = true) and import XML.


Step 14, you will need to update the record the workflow context is running on, in this case, the change record, that will restart the workflow



Reyes


Snigdha A
Giga Contributor

Hi,

I followed all of the above steps and got succeeded in resuming the workflow. But was running into another problem.

When the workflow is resumed, it worked well for first activity and progressed but got struck again at the second activity. 

This time state of context workflow is 'Executing' not canceled. Followed the same procedure by creating new workflow executing activity and made state to finished but no luck workflow is not getting progressed.

Please help me in solving this as this is on high priority. Also, let me know if there is any way to change the max activity count for the current executing workflow.

(Screenshots added for ref)

 

 

 

 

Reyes
ServiceNow Employee
ServiceNow Employee

for changing the max activity count of the current running wf, go to the wf_context, show xml, copy sys id of the wf_workflow_version field, then search by sys id on the wf_workflow_version table, export xml, on a text editor modify the max_activity_count field, import xml back.

Although this will change the max activity count, I have not tested this on an active wf.

note that max_activity_count should be about 10% more of the total number of activities on the wf, something like that, you can look at product doc.

as for the stuck activity, you can try the nudge UI action from the wf_context record, or updating the record the wf is running against.

Reyes
ServiceNow Employee
ServiceNow Employee

The steps to resume workflow from previous activity:

 

  1. From the [wf_context] record, in the related list "Workflow Executing Activities" we need to add the UI action "New." From this related list, right click between the columns  select "configured > list control" and uncheck "omit new button"
  2. Now we need the sys_id of the activity in the related list "Workflow Activity History" from which we want to go back to. Note we want the sys_id of the activity not the "workflow activity history" record, open this record, show xml, and copy the sys_id from the activity field.
  3. go back the context, create a new wf executing activities record, all fields read-only, so disable the UI policy "default read only"
  4. from the activity reference field search for the sys_id you copied from step 2, make sure record is in executing state, and submit
  5. then nudge the workflow, or update the record the wf is running against.

 

The above steps work fine for wf that are stuck because the activity went to "finish" state, due to a bad design, and now you want to the workflow to retrigger this activity again, however, if the workflow is canceled then the state (executing) and active (true) fields on the [wf_context] need to updated, for this export xml/modify/import xml.

JWALL
Mega Explorer

This worked perfect using Kingston

JWALL
Mega Explorer

Saved the day for me, thanks!

Andre Kosak
Tera Contributor

It's a kind of magic! Thank you!

Kquinton
Tera Contributor

I know this is an old thread but could this be achieved via script? If I can grab the sys_ids from the different sections. I have a situation where we need to resume a cancelled workflow but would prefer not to do the manual steps in our Prod environment. Thanks!

jcarletto27
Tera Explorer

I know it's been a bit, but for anyone with a similar problem, here's the code I came up with.

If you reached your activity limit (default: 100) you'll need to export xml your workflow version, increase the max_activity_count value and import the xml back before doing the following script.

var activity_id = "9731702fdb9bd8541ad5ef92ca96199a"; //sys_id of activity you need to restart at
var workflow_version_id = "df31742bdb9bd8541ad5ef92ca961916"; //sys_id of currently executing workflow version.
var contextList = 'dfcee459dbe9e094ab78ff27b9961999,1480cbbcdb656894edf9ca32399619ae'; //comma-seperated list of workflow context sys_ids
var array = contextList.split(",");

for (var id in array) {

    var context = new GlideRecord("wf_context");
    if (context.get(array[id]) {

        context.active = true; //required
        context.state = "executing"; //required
        context.update();

        var wf_executing = new GlideRecord("wf_executing");
        wf_executing.initialize();
        wf_executing.activity = activity_id;
        wf_executing.context = array[id];
        wf_executing.state = "executing";
        wf_executing.workflow_version = workflow_version_id;
        wf_executing.insert();

        new Workflow().broadcastEvent(array[id], 'update'); //Nudge!
    }
}
praneeth7
Tera Guru

Hello @jcarletto27 
if you can still explain this, that would be a great help for me. I am also stuck with the same phase. 

I want to know where should I copy the sys id's of context list. 

Version history
Last update:
‎02-05-2015 06:54 AM
Updated by: