Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Wait For Condition in Workflow not working for state change as cancelled

Pooja58
Kilo Sage

Hi Team,

 

We have a workflow on RITM table.

after a catalog task creation using catalog task activity, I am setting scratchpad object with this task sysID.

in next step I am using wait for condition , using scratchpad value, quering sc_task table and I am checking for state change to cancelled backend value is -10. 

workflow has reached this wait for condition but even after updating the state of task to cancelled still workflow is stuck at wait for condition activity only.

If I check for any other state like closed (backend value is 3). its working fine.

 

Any suggestions team?

bit urgent.

 

Best Regards,

Pooja

 

1 ACCEPTED SOLUTION

The workflow is running on the RITM record, so the Wait for scripts only re-runs every time there is an update to the RITM record.  Closing a Catalog task usually causes a RITM record update.  If it does not in this case, you can try to add a Business Rule to the sc_task table that forces a RITM update when a Catalog Task state changes to Cancelled. 

View solution in original post

14 REPLIES 14

Hi @Brad Bowman  ,

Inside if log it self is not displaying

And what is the 'status' shown in the logs?

Pooja58_0-1743183315623.png

It is at this stage and logs are as below state 2 is nothing but work in progress

Pooja58_0-1743183875775.png

 

 

Enhancing the logs should help see what is going wrong:

var taskGr = new GlideRecord('sc_task');
if (taskGr.get(workflow.scratchpad.sys_id)) {
    var status = taskGr.getValue("state");
    gs.info("pooja Catalog Task " + taskGR.number + " has the State " + status + " " + taskGR.getDisplayValue('state'));
    if (status == -10) {
        gs.info("pooja state inside if " + taskGR.number);
        answer = true;
    } else {
        gs.info("pooja state else " + taskGR.number);
    }
}

 

no luck,,

 

Pooja58_0-1743185632499.png