Workflow: Wait for condition activity
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 04:14 AM
Hi,
In the workflow "Wait for condition" activity is not moving further.
Expectation : It should wait till the RITM state changes to one of closed complete (3), cancelled(4) or closed skipped(7). once it meet the condition it should move to next activity but in my case "Wait for condition activity " is running not moving further
//Script written in "Wait for condition" activity
var gr = new GlideRecord('sc_req_item');
gr.addEncodedQuery("request=" + workflow.scratchpad.request);
gr.query();
if(gr.next()){
if (gr.state == '3' || gr.state == '4' || gr.state == '7'){
answer = true;
}
}
Thanks in advance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 04:18 AM - edited ‎07-28-2023 04:19 AM
Hi there,
Just wondering, can't you use the Condition field for this? What's the reason for needing to script this?
Anyway, if you nudge the workflow, is it proceeding than?
Did you also debugged the script, to see if the If is reached for example?
Perhaps instead the 3 closed stated you could also check on active=false? (which can also be added in the GlideRecord query instead of separate If condition?)
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 04:31 AM
Hello @Mark Roethof ,
Thanks for sharing your response
the reason i am using script is that,
with the current catalog item workflow, depending upon the option selected it should kick-off "xyz" catalog item. once the "xyz" RITM is state is one of closed, skipped, cancelled then only the main workflow should be complete

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-28-2023 04:42 AM
And the other questions I mentioned?
Kind regards,
Mark Roethof
Independent ServiceNow Consultant
10x ServiceNow MVP
---
~444 Articles, Blogs, Videos, Podcasts, Share projects - Experiences from the field