Adding a wait condition to a ui action

Sam Motley
Giga Guru

Hi All, 

 

I've trying to add a wait condition to a UI policy to allow a workflow to complete before the page is refreshed 

i have tried gs.sleep(); which worked in our test instance but not in production 

 

although after further investigation i've found this is not the best practice. 

Has anyone had any experience adding a wait for 5 seconds or so before redirecting to the current page? 

 

UI Action: 

Name: Submit

Table: Change_request

order: 100

script:

answer = current.insert();


gs.include('ActionUtils');


var au = new ActionUtils();


au.postInsert(current);


gs.sleep(4500);
action.setRedirectURL(current);

 

cheers 

1 ACCEPTED SOLUTION

Use a UI policy instead

 

Mike_R_0-1669821668988.png

 

Mike_R_1-1669821684525.png

 

But also with that being said, your script is using GlideRecord in a client side code. While this will work, best practices (for performance reasons) is to use GlideAJAX/client callable script include instead.

 

View solution in original post

9 REPLIES 9

Mike_R
Kilo Patron
Kilo Patron

This definitely isn't a good idea since it will cause the page to hang and also it might not operate consistently.

What exactly is the goal/requirement here? Maybe there are some other options.

Hi Mike, 

Thanks for the reply, im trying to allow time for a workflow to complete before the page refreshes 

it's quite a long workflow takes a few seconds to complete 

What kind of workflow is it, and why does it need to complete before refreshing? The workflow should run in the background so a refresh shouldn't have any impact.

 

 

cheers, it's an approval workflow for raising changes. i have a onload script that looks for conflicts in the change from the blackout calendar and if found it sets the change to emergency and notifications appear stating the change has been raised during blackout... however, because the workflow is taking a few seconds to complete there are no conflicts when the page first refreshes then a few seconds later notification of conflicts appear but my script is only on load so only refreshing it manually will show the correct notifications...

so basically i need to wait a few seconds for the conflict to appear on the change so when the page reloads the raiser is advised of the conflict and that the change has been set to emergency