How to use wait for condition -After closing Change ,RITM should be closed

Saridha_L1
Tera Expert

Hi Team.

I have created a Field in RITM table, Change Req State: Closed , Cancelled.

Once CR is closed or cancelled, value will be set in RITM Table. Its working through BR.

I need to use wait for condition,once CR Closed then only RITM should be closed. If CR cancelled, value should be set to Incomplete.

 

Please help me on this.

 

Regards,

Saridha.L

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

this can be done through wait for condition workflow activity on your item workflow. 

 

eg:

 

you can use below sample code:

 

// Set the variable 'answer' to true or false to indicate if the condition has been met or not.
//answer = true;

var gr = new GlideRecord('change_request');
gr.addQuery('parent',current.sys_id);
gr.query();
gr.next();
if(gr.state==3)
	answer = true;
else
	answer = false;

 

Note: this is sample code. make the changes based on your need.

View solution in original post

4 REPLIES 4

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

I assume your workflow would be on RITM table and update would happen on Change request table

Wait for condition in workflow would evaluate only when some update happens on that record; in this case no update is happening on RITM

So I would recommend using BR is the best approach

More details on workflow wait for condition activity:

https://docs.servicenow.com/bundle/orlando-servicenow-platform/page/administer/workflow-activities/r...

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Hi Ankur,

As you stated BR is the best approach for this. But we have other tasks to be created after wait for condition activity(which should wait until all related changed records are closed) executed. Please suggest what we can do in this scenario.

Harsh Vardhan
Giga Patron

this can be done through wait for condition workflow activity on your item workflow. 

 

eg:

 

you can use below sample code:

 

// Set the variable 'answer' to true or false to indicate if the condition has been met or not.
//answer = true;

var gr = new GlideRecord('change_request');
gr.addQuery('parent',current.sys_id);
gr.query();
gr.next();
if(gr.state==3)
	answer = true;
else
	answer = false;

 

Note: this is sample code. make the changes based on your need.

Hi Harshvardhan,

I have a wait for condition activity with the above code(mentioned by you) in the workflow, but its not triggering when the change record is closed. This code is not triggering since the modification is not happening on the ritm form.

Could you please suggest how did you resolve this issue to trigger workflow when the change record is closed.

Thank you in advance.