
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 04:13 AM
Hi,
I would like to know if anyone know the step by step procedure on how I can create a login popup message from scratch?
I wanted the users to agree to our "Terms and Conditions" upon logging in the instance and store their responses in ServiceNow.
I found some articles from SNGuru although it requires downloading a dialog which is no longer available.
Thank you in advance for the feedback!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-27-2020 05:29 AM
You can save the result either in a table or for example as a user preference. I modified the ServiceNow Guru script below:
function termsOK() {
//Gets called if the 'OK' dialog button is clicked
//Make sure terms have been accepted
var terms = gel('accept_terms').value;
if (terms != 'true') {
//If terms are false stop submission
alert('Please accept the terms and conditions to continue your order.');
return false;
}
//If accept checkbox is true do this...
GlideDialogWindow.get().destroy(); //Close the dialog window
if (!getPreference("user_accepted")) {
setPreference("user_accepted", "true")
}
}
function termsCancel() {
//Redirect gets called if the 'Cancel' dialog button is clicked
if ($('cancel_url').value != 'null') {
window.location = $('cancel_url').value;
}
else {
window.location = 'home.do'; //Redirect to default homepage
}
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2021 11:03 PM
Hi
Good Day!
May I ask where in the configuration do I input a script where it validates if the user logged in has an itil role before prompting the dialog box?
Thank you in advance!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-26-2021 11:12 PM
You can add that as a condition before you call showTerms() in the UI Script.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2021 04:46 AM
Hi Willem,
Apologies but may I know the exact script to use and where to input it?
I also have a notification setup for this and was wondering if I need to also add a condition for it to only affect the users with ITIL role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2021 04:55 AM
You can add it to the addLoadEvent as an escape like so (refer to the article if you are not sure where this is):
(2nd line contains the condition, if the user does not have the itil role, we do not want to show the popup, so we use return)
!gs.hasRole('itil')
addLoadEvent(function () {
if (!gs.hasRole('itil') || (window.name !== 'gsft_main') || (window.parent.document.URL.indexOf("login.do") > -1)) {
console.log("Prevent popup in this window or on this page.");
return;
}
var ga = new GlideAjax('global.sessionUtil');
ga.addParam('sysparm_name', 'handleSession');
ga.getXML(function (serverResponse) {
var answer = serverResponse.responseXML.documentElement.getAttribute("answer");
if(answer == 'true'){
showTerms();
}
});
});
var showTerms = function () {
var dialog = new GlideDialogWindow('terms_and_conditions_dialog'); //Render the dialog containing the UI Page 'terms_and_conditions_dialog'
dialog.setTitle('Terms and Conditions'); //Set the dialog title
dialog.setSize(600, 600); //Set the dialog size
dialog.removeCloseDecoration(); //Remove the dialog close icon
dialog.setPreference('cancel_url', 'catalog_home.do?sysparm_view=catalog_default'); //Set optional cancel redirect URL
dialog.render(); //Open the dialog
}
If you have additional questions, it might be best to log as a new question, as otherwise this thread becomes too full.