- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2019 06:28 AM
Hello,
I am trying to add an IF condition in a sc_req_item workflow to move on to the next catalog task based on the state of the previous task. So if "state" is "closed complete" it would move on to the next catalog task. If "state" is "closed incomplete" it would move to the rejection notification. Unfortunately I haven't found a good way to do this as the state in the workflow is based on the sc_req_item state and not the sc_task state. I can do it a different way if there is one like if the task is approved then move on to next task but I am not sure how to setup task approvals either.
Thank you
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2019 06:36 AM
Hi,
I think there's like 2 ways to do this, but one I know for sure would be to create that IF activity, like you wanted, and then just glide query for it...so something like:
answer = ifScript();
function ifScript() {
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 == 3) //check for task status closed complete
{
return 'yes';
}
return 'no';
}
}
So something like this, this is an example...you can create multiple outcomes to this, you can change the state we're looking for from 3 to 4 (closed incomplete), etc. Just giving a suggestion.
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2019 06:36 AM
Hi,
I think there's like 2 ways to do this, but one I know for sure would be to create that IF activity, like you wanted, and then just glide query for it...so something like:
answer = ifScript();
function ifScript() {
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 == 3) //check for task status closed complete
{
return 'yes';
}
return 'no';
}
}
So something like this, this is an example...you can create multiple outcomes to this, you can change the state we're looking for from 3 to 4 (closed incomplete), etc. Just giving a suggestion.
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2019 07:56 AM
worked perfectly. thank you!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2019 07:58 AM
Awesome!
Glad I could help.
Please also mark as Helpful, if it was.
Take care!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!