The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to set up a Wait Condition in a UI Page so form re-loads after process script complete

bpolo
Tera Guru

We have a UI Page which has a pop-up and if they click OK the processing script will run. In the processing script we call a sub-flow. Our issue is that the sub-flow updates a field, but the UI Page returns back to quickly to the form, so that the field being updated in the flow, does not reflect on the form, unless the user does a reload of the form. 
So we want to delay the form from loading until the flow is completed. We have tried the setTimeout parameter but it does not seem to work. Any thoughts would be much appreciated.

Thanks!

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@bpolo 

did you try to call that subflow in synchronous manner?

share the complete script here.

you can use inForeground() method to make it run synchronous.

AnkurBawiskar_0-1758213218258.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@bpolo 

did you try to call that subflow in synchronous manner?

share the complete script here.

you can use inForeground() method to make it run synchronous.

AnkurBawiskar_0-1758213218258.png

 

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hi Ankur

Thanks so much for your response! 

 

So here is my code in the processing script:

  var processValue = process_bypass;

 

 var urlOnStack = GlideSession.get().getStack().bottom();

 

if (processValue === "process") {

 var inputs = {};

 inputs.sir_sysid = sysparm_sys_id.toString(); // sys_id of SIR

 

 

 sn_fd.FlowAPI.getRunner().subflow('bypass_workflow').inBackground().withInputs(inputs).run();

 

 

   var message = '';

   //  ('Location Bypass Flow submitted');

    message = gs.getMessage("Successful");

 

 gs.addInfoMessage(message);

}

  response.sendRedirect(urlOnStack);

bpolo
Tera Guru

Thanks so much, Ankur! It seemed to have worked!