workflow for ritm> need to create workflow activity on if sctask is closed skipped

RBlor
Mega Guru

So, I have a workflow for a request item that creates catalog tasks. I would like to have the "IF" workflow activity to check if the sctask before it was closed skipped and if so follow the alternate path.  I have tried it and it doesnt seem to skip and follow the alternate path

 

// Check if the  SCTASK in this RITM is "Closed Skipped"
var taskGR = new GlideRecord('sc_task');
taskGR.addQuery('request_item', current.sys_id);
taskGR.addQuery('state', 4); // State 4 = Closed Skipped
taskGR.query();

if (taskGR.next()) {
    answer = true;
} else {
    answer = false;
}

 

 

RBlor_0-1740694037128.png

 

RBlor_3-1740694883910.png

 

 

 

14 REPLIES 14

Hi @RBlor, any luck on this, here is the full script:

answer = ifScript();

function ifScript() {
    // Check if the  SCTASK in this RITM is "Closed Skipped"
    var taskGR = new GlideRecord('sc_task');
    taskGR.addQuery('request_item', current.sys_id);
    taskGR.addQuery('state', 4); // State 4 = Closed Skipped
    taskGR.query();
    if (taskGR.hasNext()) {
        return 'yes';
    } else {
        return 'no';
    }
}

 


If you found this helpful, please hit the thumbs-up button and mark as correct. That helps others find their solutions.

so this is progress.  yes the workflow moved forward with no error, BUT i did close skipped and it moved forward as no

RBlor_0-1740765151489.png

 

@RBlor 

Hope your previous activity in the workflow "Catalog task" has wait checkbox. Also, try adding timer activity for 1 sec prior to IF condition.

@RBlor 

Please place yes or no in quotes and in lower case as below.

 

answer = 'yes'

RBlor_1-1740723858826.png