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

Hello Christina,



Quick question:


1.What if there are multiple tasks for a requested item? Currently I don't see you checking for multiple task.


2.Also did you mean that workflow only proceeds when u make manual update on request item?


1. You are correct. Based on where this is in the workflow it is the first task (known assumption).



2. I go here…



3.


Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Christina,



Thanks for the update. In this case, you need to trigger the workflow via script i.e use runFlows. The workflow will resume the activities only when there is an update on the item ticket.


Create a Business rule on sc_task table and trigger the item workflow as per your req.


More info here.


http://wiki.servicenow.com/index.php?title=Workflow_Script


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.