- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 08:51 AM
Hi,
Can you please provide steps to create popup window with a message after logging in to instance?
Similar like this one: https://www.servicenowguru.com/system-definition/login-terms-conditions-dialog/
Thanks,
Ashraf
Solved! Go to Solution.
- Labels:
-
Script Debugger
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 02:46 PM
I have added a check so it will not run on login page. And changed to session variable so it will trigger each new login:
addLoadEvent(function () {
var session = gs.getSession();
if (session.getClientData('popup_triggered')) {
return;
}
if ((window.name !== 'gsft_main') || (window.parent.document.URL.indexOf("login.do") > -1)) {
console.log("Prevent popup in this window or on this page.");
return;
}
session.putClientData('popup_triggered', 'true');
//Ensure that we call the dialog for the correct frame
if (window.frameElement) {
if (window.frameElement.id == 'gsft_main') {
showTerms();
}
}
else if (!window.frameElement) {
if (!$('gsft_main')) {
showTerms();
}
}
});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 02:25 PM
Thanks, this is very helpful. Let me try and how does it get invoked after login?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-24-2020 09:37 PM
I think this will show each load, so we might want to add a condition to it. If we only want it to show once try this:
addLoadEvent(function () {
var hasTriggered;
if (!hasTriggered) {
//Ensure that we call the dialog for the correct frame
if (window.frameElement) {
if (window.frameElement.id == 'gsft_main') {
hasTriggered = true;
showTerms();
}
}
else if (!window.frameElement) {
if (!$('gsft_main')) {
hasTriggered = 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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 09:59 AM
Thanks, I tried but it still loading on every page. Also, is there way we can disable navigation links until they accept or cancel button.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 10:14 AM
Can you check if it works with setting a user preference:
addLoadEvent(function () {
if (!getPreference("popup_triggered")) {
//Ensure that we call the dialog for the correct frame
if (window.frameElement) {
if (window.frameElement.id == 'gsft_main') {
setPreference("popup_triggered", "true")
showTerms();
}
}
else if (!window.frameElement) {
if (!$('gsft_main')) {
setPreference("popup_triggered", "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
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-25-2020 11:33 AM
It came only once but when I login again and I don't see that alert.
We are trying to show that alert every time when you login.
Appreciate all your help.