Catalog task State issue

dmahendran
Tera Contributor

Hey Folks,

I'm facing an issue with my ServiceNow workflow, which includes two catalog tasks. When I close the first catalog task, the second one automatically gets closed as well. The same happens when a task is canceled. I need these tasks to function independently. Additionally, I want to set the RITM state based on the task statuses, If either of the tasks is canceled, the RITM should be set to closed cancelled or If both tasks are completed, the RITM should be set to closed complete.

Any help would be appreciated!!

 

8 REPLIES 8

Viraj Hudlikar
Giga Sage

Hello @dmahendran 

 

How have setup your flow or workflow? Is there any logic setup which cancel our other ctask did you check such br or script written exclusive for that catalog item?

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

I have set up a workflow where two catalog tasks are generated based on variable choices. The requirement is to ensure that if both tasks are completed, the RITM state updates to closed completed, whereas if either of the tasks is canceled, the RITM should be set to closed canceled. I attempted to achieve this using an if condition, but it is not functioning as expected. I need guidance on how to implement this logic correctly so that the RITM state updates accurately based on the status of the catalog tasks.
Attaching the snip below

Hello @dmahendran 

 

In your workflow you have use join activity but it doesn't perform check whether all task are completed or is any one incomplete you will need additional if activity which will check what is status of all ctask, below is sample workflow in my PDI:

VirajHudlikar_0-1742278670585.png

 

Script in If block after join activity is as followed:

answer = allCompleted();

function allCompleted(){
	var completed = 0;
	var count;
	var grTask = GlideRecord('sc_task');
	grTask.addQuery('request_item',current.sys_id);
	grTask.query();
	count = grTask.getRowCount();
	while ( grTask.next() ){
		
		if (grTask.getValue('state') === '3') {
			completed++;
		}		
	}	
	return count === completed ? 'yes' : 'no';
}

 

When any one ctask is mark as close incomplete the ritm goes in close incomplete state

VirajHudlikar_1-1742278820340.pngVirajHudlikar_2-1742278832393.png

If all Ctask are complete, then below is working:

VirajHudlikar_3-1742278903721.png

VirajHudlikar_4-1742278926261.png

 

If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.

 

Thanks & Regards
Viraj Hudlikar.

@Viraj Hudlikar Thanks for your response.

I didn’t implement any approval state before the "Request Approved" state in my flow, but I still see a "Waiting for Approval" stage appearing. I'm trying to figure out why this stage is showing up. I'll attach a snippet of the flow—let me know if you spot anything that might be causing this stage issue. When we raised the request i want the request state to be approved rather then showing as waiting for approval.