Add New State on Catalog Task: Workflow Not Working

Ishan Bajaj
Giga Expert

Hello Team,

This is regarding the new state on Catalog Task table.

Issue: Have added new state choice as 'Closed Cancelled (9)' under catalog task/task table. Now, when my workflow reaches the catalog task where I have two conditions i.e. Closed Complete: activity.result == 3  & Closed Cancelled: activity.result == 9

If user mark the task as closed complete no issue workflow works and goes to next activity BUT if user mark the task as closed cancelled then workflow gets stuck and doesn't move forward.

Troubleshooting:

1. Have checked with different closure states i.e. Closed Incomplete, Closed Skipped its working as these states are defined OOTB

2. Have checked one BR i.e. SNC - Run parent workflows + associated Script Include - TaskStateUtil().canRunParentWF(current) and added the new state but it doesn't work.

ScreenShot:

1. Task state:-

find_real_file.png

2. Sample Workflow - Have created to check the conditions:-

find_real_file.png

 

Has anyone done these changes in your engagements. If yes, can you please provide solution.

21 REPLIES 21

Thank you so much:)

Ishan Bajaj
Giga Expert

Hello All,

 

It seems there is limitation here from ServiceNow end. So to achieve the business requirement, have write the below logic through Business Rule.

After - Update Operation

 

Condition - State changes to Closed Cancelled And *Add more based on your requirement*

 

Script:-

var getRITM = current.request_item;

//Cancel RITM and associated workflow
var grRITM = new GlideRecord('sc_req_item');
grRITM.addQuery('sys_id',getRITM);
grRITM.query();
if(grRITM.next()){
grRITM.active = false;
grRITM.state = 9;
var workflow = new Workflow();
workflow.cancel(grRITM);
grRITM.setWorkflow(false);
grRITM.update();
}

//Cancel Any Active Open Task
var grTask = new GlideRecord('sc_task');
grTask.addQuery('request_item',getRITM);
grTask.addQuery('sys_id','!=',current.sys_id);
grTask.addActiveQuery();
grTask.query();
if(grTask.next()){
grTask.state = 3;
//grTask.active = false;
//grRITM.setWorkflow(false);
grTask.update();
}

current.active = false;
current.setWorkflow(false);
current.update();

 

If my answer helped you in any way, please then mark it as helpful.

Kind regards,
Ishan