Moving to next catalog task based on previous task state in workflow

ZGauss
Tera Expert

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

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

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!

View solution in original post

3 REPLIES 3

Allen Andreas
Administrator
Administrator

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!

worked perfectly. thank you!

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!