- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 04:10 AM
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
Solved! Go to Solution.
- Labels:
-
Incident Management
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 07:22 AM
Use a UI policy instead
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 07:09 AM
Any particular reason why you can't use the OOTB conflict detection? The you can create a before update business rule to automatically change the type to emergency if a conflict is found
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 07:14 AM
Hi Mike, we are using this is how the conflict is found initially
it's just because there's a few seconds delay the conflict takes a few secs to appear and my blackout notification is based on the conflict being present
Please find below the script:
function onLoad() {
var conflicts = new GlideRecord('conflict');
var sys = g_form.getUniqueValue();
conflicts.addQuery('change', sys);
conflicts.addQuery('type', 'blackout');
conflicts.query();
if (conflicts.hasNext()) {
g_form.addInfoMessage('<font color="red">THIS CHANGE HAS BEEN RAISED DURING A CHANGE FREEZE</font>');
if(g_form.getValue('u_emergency') == 'No'){
g_form.addInfoMessage('<font color="red">THIS CHANGE HAS BEEN SET TO EMERGENCY, PLEASE REVIEW AND SUBMIT</font>');
g_form.setValue ("u_emergency","Yes");
alert("RED ALERT – This change has been raised during a CHANGE FREEZE");
}
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 07:22 AM
Use a UI policy instead
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-30-2022 07:46 AM
Thanks Mike really appreciate the assist
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-25-2023 09:06 AM
Tried this and it worked. Update the fields that need to be updated first, then do a second update with the "setWorkflow(false)". See my script below
var gr_inc_resolved = new GlideRecord('incident');
gr_inc_resolved.addEncodedQuery(query_inc_resolved);
gr_inc_resolved.query();
while (gr_inc_resolved.next()) {
gr_inc_resolved.u_state_reason = "QA Verified Successful";
gr_inc_resolved.work_notes = "Incident is auto closed after 7 days";
gr_inc_resolved.update();
gr_inc_resolved.state = 7; // Closed
gr_inc_resolved.setWorkflow(false);
gr_inc_resolved.active = false;
gr_inc_resolved.update();
}