- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-07-2020 11:50 PM
Hi All,
I need to disable a ui page which is triggered but based on certain condition.
Points to consider:
1. Alert page is displayed when user clicks 'approve n send' and expected review time is not met.
2. In my current setup, when user cancel on Alert page, validation page reloads.
3.When ui page 2 - 'Alert' is displayed, ui page 1 'validation' should be disabled.
Reason to do this is at the moment the fields are editable even if page 2 loads.
My question - How can we disable the validation page when alert page loads ?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2020 03:18 AM
Update on my question:
Solution:
In client script have passed id's for each field ie to,cc,bcc,subject and body and button to make the fields readonly.
var ok = document.getElementById("ok_button");
ok.style.display = "none";
var cncl = document.getElementById("cancel_button");
cncl.style.display = "none";
var to_readonly = document.getElementById("TO_unchecked");
to_readonly.disabled = 'true';
var cc_readonly = document.getElementById("CC_unchecked");
cc_readonly.disabled = 'true';
var bcc_readonly = document.getElementById("BCC_unchecked");
bcc_readonly.disabled = 'true';
var subjecy_readonly = document.getElementById("subject");
subjecy_readonly.disabled = 'true';
var body_readonly = document.getElementById("Body");
body_readonly.disabled = 'true';
The ids are defined in html part of 1st ui page.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2020 12:04 AM
Hi, Could you provide the client script of both UI Pages. Are they out of the box or Custom?
Please mark Correct and click the Thumb up if my answer helps you resolve your issue. Thanks!
Martin Ivanov
ServiceNow MVP 2023, 2024
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2020 12:14 AM
Hi Martin,
These are custom ui page.
Validation page client script:
function onCancel() {
GlideDialogWindow.get().destroy();
return false;
}
function allSelect() {
var x = document.getElementById("emailForm");
var selectValue = document.getElementById('select_all').checked;
for (j = 0; j < x.length; j++) {
var txt = x.elements[j].id;
if (txt.indexOf('TO_') != -1) {
document.getElementById(txt).checked = selectValue;
}
if (txt.indexOf('BCC_') != -1) {
document.getElementById(txt).checked = selectValue;
} else if (txt.indexOf('CC_') != -1) {
document.getElementById(txt).checked = selectValue;
} else {}
}
}
function SendEmail_UI() { //this is called when approve n send button is clicked.
document.getElementById('subject').innerHTML = true;
var x = document.getElementById("emailForm");
var txt = "";
var i, j;
var TO = '';
var CC = '';
var BCC = '';
var attachmentIds = '';
var ALL_TO = '';
var ALL_CC = '';
var ALL_BCC = '';
var ALL_TO_LENGTH = 0;
var attchmentViewed = 0;
var attchmentCount = 0;
var checkedattchmentCount = 0;
for (j = 0; j < x.length; j++) {
txt = x.elements[j].id;
if (txt.indexOf('TO_') != -1) {
if (ALL_TO == '')
ALL_TO = txt.substring(3, txt.length);
else
ALL_TO += "," + txt.substring(3, txt.length);
ALL_TO_LENGTH++;
}
if (txt.indexOf('BCC_') != -1) {
if (ALL_BCC == '')
ALL_BCC = txt.substring(4, txt.length);
else
ALL_BCC += "," + txt.substring(4, txt.length);
} else if (txt.indexOf('CC_') != -1) {
if (ALL_CC == '')
ALL_CC = txt.substring(3, txt.length);
else
ALL_CC += "," + txt.substring(3, txt.length);
}
if (txt.indexOf('email_attachment_') != -1) {
attchmentCount++;
if (document.getElementById(txt).style.display != 'none')
attchmentViewed++;
if (attachmentIds == '')
attachmentIds = txt.substring(17, txt.length);
else
attachmentIds += "," + txt.substring(17, txt.length);
}
}
for (i = 0; i < x.length; i++) {
txt = x.elements[i].id;
if (document.getElementById(txt).checked == true) {
if (txt.indexOf('TO_') != -1) {
if (TO == '')
TO = txt.substring(3, txt.length);
else
TO += "," + txt.substring(3, txt.length);
}
if (txt.indexOf('BCC_') != -1) {
if (BCC == '')
BCC = txt.substring(4, txt.length);
else
BCC += "," + txt.substring(4, txt.length);
} else if (txt.indexOf('CC_') != -1) {
if (CC == '')
CC = txt.substring(3, txt.length);
else
CC += "," + txt.substring(3, txt.length);
} else if (txt.indexOf('email_attachment_') != -1) {
checkedattchmentCount++;
if (attachmentIds == '')
attachmentIds = txt.substring(17, txt.length);
else
attachmentIds += "," + txt.substring(17, txt.length);
}
}
}
if (ALL_TO_LENGTH == 0) {
alert('To is mandatory, make sure to address are not blacklisted');
return false;
}
if (TO != ALL_TO || CC != ALL_CC || BCC != ALL_BCC) {
alert(" Emails: There are items that have not been confirmed. Please review and check all items prior to sending.");
return false;
}
if (document.getElementById('subject').checked != true) {
alert("There are items that have not been confirmed. Please review and check all items prior to sending.");
return false;
}
var count_to = 0;
var count_cc = 0;
var count_bcc = 0;
var data_to = document.getElementsByName("TO_false");
var data_length_to = data_to.length;
var data_cc = document.getElementsByName("CC_False");
var data_length_cc = data_cc.length;
var data_bcc = document.getElementsByName("BCC_False");
var data_length_bcc = data_bcc.length;
var total_unchecked_users = data_length_to + data_length_cc + data_length_bcc;
var time_users = total_unchecked_users * 5;
var time_body = 3;
var time_subject = 3;
var standard_review_time = time_users + time_body + time_subject;
var d = new Date();
var nowTime = (d.getTime()) / 1000; // get value in seconds
var initialTime = gel('hiddenValue').value;
var initialTimeSeconds = initialTime / 1000; // get value in seconds
var review_time = nowTime - initialTimeSeconds;
review_time = review_time.toFixed(1);
if (review_time < standard_review_time) {
var dialog = new GlideDialogWindow('Alert');
dialog.setTitle(""); //Set the dialog title
dialog.setPreference('Review time', review_time);
dialog.setPreference('Standard review time', standard_review_time);
dialog.setSize(400, 200);
dialog.render();
return false;
} else {
alert('You have taken standard time to review the page');
updateRitm();
GlideDialogWindow.get().destroy();
return true;
}
}
function restartwindow() {
var labelValue = document.getElementById("emailIdList").value;
GlideDialogWindow.get().destroy();
setTimeout(function() {
openPage(labelValue);
}, .001);
}
function openPage(value) {
var dialog = new GlideDialogWindow('disclaimer');
dialog.setTitle(""); //Set the dialog title
dialog.setPreference('email_ids', g_form.getValue('u_to'));
dialog.setPreference('sys_id', g_form.getUniqueValue());
dialog.setPreference('ccemail_ids', g_form.getValue('u_cc'));
dialog.setPreference('bccemail_ids', g_form.getValue('u_bcc'));
dialog.setPreference('bclist_ids', 'test_blacklist@gmail.com');
dialog.setPreference("subject", g_form.getValue("short_description"));
dialog.setSize(750, 300);
dialog.render();
}
function updateRitm() {
GlideDialogWindow.get().destroy();
g_form.setValue('description', 'Updating description test567');
g_form.setValue('work_notes', 'Updating work notes test 567');
}
===========================
Client script of Alert page:
function onCancel() { // this is reloading 1st page
restartwindow();
GlideDialogWindow.get().destroy();
}
function submit() {
GlideDialogWindow.get().destroy();
updateRitm();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2020 01:49 AM
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2020 04:41 AM
c