Workflow activity 'Wait for Condition' always needs a 'Nudge'

clyon
Tera Guru

I have the following 'Wait for Condition'   script. When   the step runs the first time the value is 'requested'.   Whether it is 'approved' or 'rejected' the activity won't trigger when the approval/rejection is done and the task 'parent status approval' is updated.

I get the workflow to continue I have to go into the activity context for the RI and 'Nudge' the workflow, and then it continues on as it should. What am I missing?   TIA

//*****************Need to check approval record*****************

var grTask = new GlideRecord('sc_task');

grTask.addQuery('request_item', current.sys_id);     ///'RITM0011604');

grTask.query();

if(grTask.next()) {

  gs.log('BS Decision-' + grTask.approval);

  if (grTask.approval == 'approved' || grTask.approval == 'rejected' )   {

  answer = true;

}

}

find_real_file.png

13 REPLIES 13

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Can you please paste the script here.


//****************Need to check approval record****************


var grTask = new GlideRecord('sc_task');


grTask.addQuery('request_item', current.sys_id); ///'RITM0011604');


//grTask.addQuery('approval', 'approved');


//grTask.addOrCondition('approval', 'rejected');


grTask.query();




if(grTask.next()) {


gs.log('BS Decision-' + grTask.approval);


if (grTask.approval == 'approved' || grTask.approval == 'rejected' ) {


answer = true;


}


// else { answer = false;


// }


}


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

I think this goes as part of your workflow activity run script. You need to create a BR on sc_task table to trigger the workflow.


Isn't this what you are referring to?



I have created a business rule as you mentioned. I'm really not sure if the script needs to be changed or not.


The Wait for condition still isn't continuing after the parent approval status on the task is updated.







Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Thanks for the details and screenshot. I don't see any issues with the script.


I can take a look and debug if this is on your personal dev instance.