- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 05:12 PM
Hi all,
I created a UI Action that automatically sets an asset state to "Missing," but I'm trying to add a modal that shows a short message and then prompts the user to click on "Cancel" or "Report as Missing." A flow is automatically triggered when an asset state changes to this state, so we're trying to ensure a second validation before the final submission.
Below is my UI Action code:
function reportmissing() {
var dialogClass = GlideModal ? GlideModal : GlideDialogWindow;
var miss = new dialogClass('update_asset_missing');
miss.setTitle(getMessage('Confirm'));
gsftSubmit(null, g_form.getFormElement(), 'report_missing');
}
if (typeof window == 'undefined') {
current.install_status = "8";
current.update();
//will be on the current page after UI action
action.setRedirectURL(current);
}
How can I add that to my script?
Thank you
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2022 06:55 PM
@taofeek93 Tried and tested solution
Create a UI action as below
UI Action code:
function reportMissing() {
var gm = new GlideModal('report_missing_ui_page');
gm.setTitle('Confirm');
gm.setWidth(400);
gm.render();
}
Create a ui page as below:
UI Page HTML:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<p>Are you sure you want to mark it as report missing?</p>
<br/>
<div style="float: right">
<g:dialog_buttons_ok_cancel ok="return setState()" ok_type="button" ok_text="Report as Missing" ok_style_class="btn btn-primary" cancel="return destroyWindow()" cancel_type="button" cancel_text="cancel" cancel_style_class="btn btn-default" />
</div>
</j:jelly>
UI Page Client Script:
function setState() {
g_form.setValue("install_status", "8");
g_form.save();
destroyWindow();
}
function destroyWindow() {
GlideDialogWindow.get().destroy();
}
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 06:05 AM
See attached screenshots:
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 06:08 AM
@taofeek93 the function in onclick field and the one which is in script are different
Please make both as reportMissing
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 06:55 AM
Worked great - Thank you!
One more thing please; how can I change the UI action button color to Red?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 07:18 AM
@taofeek93 Mark the "Form style" as destructive.
ServiceNow Community Rising Star, Class of 2023