39 views

Symptoms


The workflow gets stuck on the Approval Coordinator activity if the activity doesn't result in any approvals or if the approvers are Inactive.

Cause


Prior to Jakarta the Approval Coordinator workflow activity did not include a condition "activity.result == 'skipped'".

As a result, if the Approval Coordinator has a result 'skipped' in the workflow context, it gets stuck and the workflow can not proceed to the next activity.

Resolution


Steps to follow:

1. Gather the list of workflow conditions which do not have the "activity.result =='skipped" condition and whose Activity Definition is an "Approval Coordinator".

   Try this URL: 

https://instance_name.service-now.com/wf_condition_list.do?sysparm_query=name%3DApproved%5Eactivity.activity_definition%3D283e8bb80a2581021d036a052ffc3433%5Eactivity.workflow_version.published%3Dtrue

2. From the list view, update the condition column with the following line: activity.result == 'approved' || activity.result == 'skipped'

    This will ensure that the workflow will not get stuck for the new records.

Now, to fix the workflow contexts which are stuck on the Approval Coordinator, follow the below steps:

3. Get the list of workflow activities that are stuck and has a result value ‘skipped’.

You can use the below URL to grab the list:

https://instance_name.service-now.com/wf_history_list.do?sysparm_query=result%3Dskipped%5Estate%3Dfinished%5Econtext.state%3Dexecuting%5Eactivity.activity_definition%3D283e8bb80a2581021d036a052ffc3433

4. From this list, we have to get the sys_id’s of the Workflow contexts that are stuck.

Run the below script in the Scripts-Background which will return a list of sys_id’s

******

var queryString = "result=skipped^state=finished^context.state=executing^activity.activity_definition=283e8bb80a2581021d036a052ffc3433"; 
var wh = new GlideRecord('wf_history'); 
wh.addEncodedQuery(queryString); 
wh.query(); 
while(wh.next()) 

gs.log(wh.context.toString()); 

******* 

Once we have the sys_id’s ready, we should run a Script that updates all the stuck workflow contexts and move the workflow.

Attaching “Script_for_ApprovalCoordinatorGotStuck_v2.js” to the KB article.

5. Run the attached script in the Scripts-Background which will fix the workflow contexts that are stuck.

Note:

> This script will be require to add a comma-separated list workflow context to be fixed under variable "contextList"
e.g.: 
var contextList = "555a7e8a87311300a02fa1bb36cb0b80,855a3e8a87311300a02fa1bb36cb0be2";

> The workflows will be fixed after all records created under table ‘wf_command’ are processed.

> It takes some time for the script to update all the workflow contexts.



-Same steps to follow:

1. The script must be validated internally e.g.: using employee instance with a similar customer workflow (activities used) as possible. 

2. On customer side, the script must be validated on a test instance with a significative load of workflows contexts with the issue. 

3. Only after the script was successfully validated on a customer test instance then could be executed on a production instance.

 

Article Information

Last Updated:2018-09-27 10:45:25
Published:2018-09-27