We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

wait for condition

chandan2212
Tera Contributor

Hi All, 

 

I am writing the script in the sc_request workflow (wait for condition) that  untill the all the RITM is not approved the REQ show requeste but below script is not working in the wait for condition.

answer = (function () {
    if (!current || !current.sys_id) return false;
    var reqId = current.sys_id.toString();

 

    // 1) If any child is still waiting for approval 
    var waiting = new GlideRecord('sc_req_item');
    waiting.addQuery('request', reqId);
    waiting.addQuery('approval', 'requested');
    waiting.setLimit(1);
    waiting.query();
    if (waiting.next()) return false;

}

 

 

Can you guide me to resolve the issue.

1 REPLY 1

GlideFather
Tera Patron

Hi @chandan2212,

 

and where do you use this script?

 

Maybe you want to create a new flow (ex-Flow designer, currently called Workflow studio) there is a Wait until functionality implemented and works reliably without a need of customisations.

 

You can define a period of time to be waited or waiting until a specific condition is met:

Screenshot 2026-03-05 at 09.59.46.png

 

Perhaps this could be easier for you to implement. What do you think?

 

 

_____
100 % GlideFather experience and 0 % generative AI