- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 07:39 AM
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
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2020 08:11 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2020 07:48 AM
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:
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2024 12:29 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2020 08:11 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-02-2024 06:49 AM
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.