- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 09:29 PM
Hi there,
I created a UI page that displays Yes/No button. Based on the user input selection the actions gonna take place. But the user is still able to close the UI page using the "cross mark" without selecting any input. That should not happen.
Please help me in removing that "cross mark" and also I want to place this UI popup at the top of page instead of center.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 10:09 PM
Hi,
You can use this code and it would show the confirm box with Yes/No and it comes in center
var dialog = new GlideModal('glide_modal_confirm', true, 300);
dialog.setTitle('Confirmation');
dialog.setPreference('body', 'Is there a Cost impact?');
dialog.setPreference('focusTrap', true);
dialog.setPreference('onPromptComplete', doComplete);
dialog.setPreference('onPromptCancel', doCancel);
dialog.render();
function doComplete() {
callback(true);
}
function doCancel() {
callback(false);
}
Output:
If my response helped please mark it correct and close the thread so that it benefits future readers.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2022 10:43 PM
Hi,
Glad to know that my script worked.
It's an OOB and comes from platform level.
Please mark my response as correct and helpful and close the thread.
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 03:24 AM - edited 09-21-2023 03:25 AM
Hello @Ankur Bawiskar
I have created a UI Page and if a user changes the state of sc_task to 'closed incomplete' then a custom popup will display with additional comment field mandatory. However, if the user clicks the (X) on the dialog box and saves, the record gets saved, which breaks the popup functionality.
I hope if we reload the form on click of (X) will solve this. Can you please suggest a way.
function onChange(control, oldValue, newValue, isLoading, isTemplate) {
if (isLoading || newValue === '') {
return;
}
// Check if the state is changing to '4'
if (newValue == '4') {
var assignedTo = g_form.getValue('assigned_to');
// Check if 'assigned_to' is empty
if (!assignedTo) {
// Display an error message
g_form.addErrorMessage('Please fill in the "Assigned To" field before closing the task.');
g_form.setValue('state', oldValue);
return;
}
// If 'assigned_to' is not empty, proceed with the popup window
var sysId = g_form.getUniqueValue();
var dialogClass = GlideModal ? GlideModal : GlideDialogWindow;
var dialog = new dialogClass('IC-Stop_Closure_Of_ScTask');
dialog.setTitle(getMessage('Task Closure Reason'));
dialog.setPreference('sysparm_sys_id', sysId);
dialog.setPreference('sysparm_ok_button_name', getMessage('Ok'));
dialog.on('closeCompleteSuccess', function () {
dialog.destroy();
gsftSubmit(null, g_form.getFormElement(), 'sysverb_update_and_stay');
});
dialog.render();
}
}
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 04:10 AM
why to use UI page and not make the comments mandatory via UI policy?
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-21-2023 04:19 AM
Hello @Ankur Bawiskar
You are absolutely correct, the customer requested a custom popup.
Thanks & Regards
Vrushali