Workflow - Wait for condition
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 04:24 AM
Hi! Need help in workflow(sc_request) wait for condition activity...
I have this workflow and we just need to create a "Wait for condition" ,so that if the answer is true, it will create task (another workflow activity)
The script seems fine to me but this didnt work(tried to check it many times), it didn't go to the next Workflow activity (Create Task)...
Appreciate any help
var req = current.sys_id;
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', req);
ritm.query();
while (ritm.next()) {
var optMtom = new GlideRecord('sc_item_option_mtom');
optMtom.addQuery('request_item', ritm.sys_id);
optMtom.query();
while (optMtom.next()) {
var opt = new GlideRecord('sc_item_option');
if (opt.get(optMtom.sc_item_option)) { //dependent item from optMtom
if (opt.item_option_new.name == 'return_item' && opt.value != '') {
answer = true;
break;
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 04:36 AM
Hi @Dizy M ,
this works if the return_item is already set on the RITM
if you are expecting this to work with variable value update on the RITM it might not work
there has to be some update on the Request table for wait for condition reevaluate
answer =false;
var req = current.sys_id;
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', req);
ritm.query();
while (ritm.next()) {
if (ritm.variables.return_item) {
answer = true;
break;
}
}
you can put this in the wait for condition script
and also when the value is filled in the variable try updating the request record
you need to come up with some solution like a BR or a flow something which would update the request record as soon as the value on the variable changes so the wait for condition reevaluates on the workflow
hope this make sense
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 04:57 AM
Did you create a custom workflow on sc_request table?
OOTB there is already 1 on sc_request and you should not touch workflow on sc_request table
what's your business requirement?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 05:23 AM
Hi @Ankur Bawiskar - It's a custom workflow for sc_request.
We have this variable ("return_item") in our Catalog item. When the user creates a request and if the variable is not empty it should create a task . But if the user creates a request and the variable is "EMPTY" , it should not create a task , we have to wait until the user put a value in the variable and this will create task.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-24-2025 05:32 AM
why are you having custom workflow on sc_request? You should always use the OOTB one which I shared above.
Not a good practice.
Also you need to create a task which I believe is catalog task then you should either use Flow Designer with "Service Catalog" trigger for your Catalog item
OR
You can use workflow editor
If you are using flow designer then you can wait until that variable is filled and once filled the flow can proceed and create catalog task
check these links on how it can be done
Flow Action: Wait for condition where checkbox variable is checked
How can w use wait for condition in flow designer for variable? - response from Anil
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader