- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 02:58 AM
Hello All,
I want to check TASK status in the workflow, if TASK is closed I want Make RITM and REQ closed and If TASK is cancelled I want to Make RITM/REQ cancelled, I want check task status in work flow and then set up RITM/REQ status from workflow, please find the below screen shot
Thanks
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 10:25 PM
Finally got the solution
Since the workflow is on the Requested item, current.task.state refers to current requested item status which is not closed complete. hence all the requested items are going to cancelled state. use below script after the catalog task activity.
answer = check();
function check()
{
var gr_tsk = new GlideRecord("sc_task");
gr_tsk.addQuery('request_item', current.sys_id);
gr_tsk.query();
gr_tsk.next();
if(gr_tsk.state == 4) //check for task status closed incomplete
{
return 'yes';
}
return 'no';
}
after if, for yes you will have Set values activity with status and stage as Closed complete and completed respectively. for no, it will be Closed incomplete and Request Cancelled.
remember, this will work if there is only one task for the requested item.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 04:27 AM
can you give a try with other state value , just to check if it's an issue with state value or something else.
adding doc link here,
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 05:08 AM
That Cancelled state choices is custom one will it work .

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 06:47 AM
only the state value which has mentioned in the doc will work.
Cancelled state is already mentioned , can you try to set the value as Cancelled and see if it is working or not.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-18-2019 02:40 AM
Hi Harsha,
Thanks for the response and quick conversation, I have created if activity after my task activity and written logic inside the if activity script condition.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-17-2019 10:25 PM
Finally got the solution
Since the workflow is on the Requested item, current.task.state refers to current requested item status which is not closed complete. hence all the requested items are going to cancelled state. use below script after the catalog task activity.
answer = check();
function check()
{
var gr_tsk = new GlideRecord("sc_task");
gr_tsk.addQuery('request_item', current.sys_id);
gr_tsk.query();
gr_tsk.next();
if(gr_tsk.state == 4) //check for task status closed incomplete
{
return 'yes';
}
return 'no';
}
after if, for yes you will have Set values activity with status and stage as Closed complete and completed respectively. for no, it will be Closed incomplete and Request Cancelled.
remember, this will work if there is only one task for the requested item.