ServiceNow provides various methods for logging users into an instance. Local login, LDAP, SAML, and Digested Token are all used pretty regularly by customers. One thing that is often requested, but usually not successfully addressed, is the need to have the logged-in user accept some terms or conditions of use before they are allowed to use the system. The solutions attempted before usually suffered from a variety of issues ranging from overly-complex modification of one or more installation exits to being able to easily bypass the terms page entirely. In the end, these solutions seemed to be broken on some level. As we’ve seen requests for this type of functionality increase over the past few months, Jacob Andersen (who developed almost all of the integration and SSO information at SNCGuru) and I decided to collaborate to create a solution that actually works!
Features:
- Use the same way no matter what authentication method you’re using!
- No messy, complex modifications of installation exits
- Dialog-based acceptance page ensures no interference with user login or deep-linking
- Complete logging of each user interaction with the dialog
- Use of properties and message to disable or enable the terms page at whatever interval you want, set logging level, and customize the dialog text
- Multi-language, multi-company support built-in
Components and Usage:
This SNCGuru solution is packaged as an update set for easy installation in your instance. Included in the update set are the following elements…
- TermsAcceptance UI script – This global UI script is what initiates the entire process. When a user attempts to view any page in the system, the UI script runs and makes a call to the ‘TermsAcceptanceAjax’ script include to see if terms have been accepted for the user session. If not, the UI script triggers a dialog with the terms.
- TermsAcceptanceAjax Script include – Does most of the heavy-lifting in the background to check user terms acceptance for a session and set and record acceptance and cancellation by each user as it happens.
- terms_acceptance_dialog UI page – Contains the dialog contents that are displayed to the user and calls back to the ‘TermsAcceptanceAjax’ Script include to record and log terms acceptance details. Dialog logo image is dynamically pulled in based on the user’s company.
- terms_acceptance.message Message record – Accessed by navigating to ‘System UI -> Messages, this message contains the actual text of the terms dialog. Simply add whatever HTML you want to this message record to modify the text of the dialog. Use of a message record for the text allows for multi-language support as well.
- ‘Frequency (in days) that users must accept terms’ (terms_acceptance.interval) and ‘Log level of Terms/Acceptance page’ (terms_acceptance.log) system properties – These can be found under the ‘System Properties -> Terms Acceptance’ module. ‘terms_acceptance.interval’ allows you to disable the terms page completely or enable it to trigger at any daily interval. Use ‘-1’ to disable the terms page, ‘0’ to enable for every session, or any other daily interval as necessary. ‘terms_acceptance.log’ controls whether you log user acceptance, cancellation, both, or none of the above in the ‘Terms Acceptance’ table
- Terms Acceptance table – Logging table for all user interactions with the terms dialog. If the ‘terms_acceptance.log’ property is set to log user interactions, they will be stored in this table. The ‘Terms Acceptance’ table can be accessed by navigating to ‘System Logs -> Terms Acceptance’
- Flashcanvas UI script
You can view the update set and installation instructions here…
Related Links:
- Download: Login Terms Acceptance Dialog
- Supporting Documentation: Installing an update set on your instance
Nice!
Mark, I’d love to utilize this but we are running into an issue. When logging in it fires for users with an admin role, for all other roles it bypasses it and doesn’t fire until they try to pop open a new window or tab. Any idea what object might be firing between the user login and the UI script that kicks off the Terms and Acceptance process. Any suggestions would be greatly appreciated
Thanks for the feedback. I think I can reproduce the issue but it would help if you could clarify a couple of things for me. Does the issue occur for users with roles (like itil) or just for users with no roles at all? Also, does the issue occur if you use the CMS portal? https://yourinstance.service-now.com/ess
My testing shows that this only happens for end users (those with no role at all) and that it only happens in the regular interface, not in the CMS interface.
Mark,
Thanks for your quick response. It seems to affect everyone that is not a full admin. However when I used the CMS portal it did pop the terms and conditions as expected. We’ve tried various different role combinations and have not had it successfully fire except when they have the role “admin”.
I think I’ve got a fix. What I discovered is that the system loads its outer frame differently for users with no roles. This required me to modify how the dialog selects the frame it should be displayed in. The required behavior now is to load the dialog in the main inner content frame when the system is displayed in the standard frame set. You should be able to fix your issue by pasting this code into the ‘TermsAcceptance’ UI script. I’ve added a new update set to do the same. Please let me know how this works for you.
//Ensure that we call the dialog for the correct frame
if(window.frameElement){
if(window.frameElement.id == 'gsft_main'){
checkTerms();
}
}
else if(!window.frameElement){
if(!$('gsft_main')){
checkTerms();
}
}
});
function checkTerms() {
//See if the user has accepted terms for this session
var ga = new GlideAjax('TermsAcceptanceAjax');
ga.addParam('sysparm_name','getSessionVariable');
ga.addParam('sysparm_var_name','agreed_to_terms');
ga.getXML(getTermsAcceptanceFromSession);
}
function getTermsAcceptanceFromSession(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//If no terms acceptance display the dialog
if (!answer){
showTermsDialog();
}
}
function showTermsDialog(){
//Initialize and open the Dialog Window
//Render the dialog containing the UI Page 'terms_acceptance_dialog'
var dialog = new GlideDialogWindow('terms_acceptance_dialog');
dialog.setTitle('Terms and Conditions'); //Set the dialog title
dialog.setSize(500,400); //Set the dialog size
dialog.removeCloseDecoration(); //Remove the dialog close icon
dialog.render(); //Open the dialog
//Customizations for dialog background color and opacity
var d = $('grayBackground');
d.style.opacity = "1"; //Opacity setting for normal browsers
d.style.filter = "alpha(opacity = 100)"; //Opacity setting for IE
//d.style.backgroundColor = "blue"; //Optional background color setting
//d.style.backgroundImage = "url('http://sncguru.com/logo.png')"; //Optional background image setting
//Automatically adjust the size of the dialog as window dimensions change
Event.observe(window, 'resize', function() {
var dims = document.viewport.getDimensions(); // dims.width and dims.height
d.style.width = dims.width + 'px';
d.style.height = dims.height + 'px';
});
}
This works perfectly! Thank you!
I’m using the login terms, and everything works great. However I’m trying to get the login terms to either fill the entire right pane, or the entire page? Based on the no role issue above it appears that maybe I could just call to a different frame?
Mark, have you tried this on the Dublin release? I just found the script, looks cool and something we might utilize, I loaded it on our Dublin instance and it just comes up with dialog box and says loading and goes nowhere.
Mark,
your solution is exactly what i need but it is not running on the Dublin release. any hints on how to solve this?
thanks
I just installed this on demo003 and it’s working fine there. Have you tried installing the solution on a SN demo instance?
very nice.. used it for slightly different requirement, your package was very useful
Thank you! I’m glad it helped!
My colleague has used this and it works fine however we need to refine further to display with the CMS portal. The issue being that the portal is https://nstance.service-now.com/solveit and the logo for this is held within Content Management > Headers > solveIT – Header
can you provide any guidance how I may be able to adapt this further to check for this.
I have checked with a user who has no roles, and signed into the ess portal and it doesnt display the popup – even with the main company logo.
many thanks
Hello, I’m confused as to the exact issue you’re having. It sounds like you want to pull the logo from the CMS header (you’ll have to query for the header record to get to that but it’s probably better in a separate system property). It also sounds like it might not be showing up at all in the CMS? I’ve confirmed that to be working in the past so I’m not sure what the issue might be there. You might try it in a SN demo instance and see if it works there.
just to let you know that we fixed this – it was something that we had added internally which was causing the issue
regards
Nikki
When the user has configured the ‘new UI’ with the edge to use a flyout page, this flyout overlays the acceptance dialog. The dialog is within the main frame (at z-index 1000) and the flyout is outside the main frame (at z-index 900).
Any ideas on getting the dialog on top of the flyout ?
Marc
Hi Mark,
I am using this terms and acceptance its working perfect.One quick question, Some time we dont want to show the terms message, in that time we are updating the terms.message with empty content.,but it is visible to users with “term.acceptance.message”
can we handle any condition for messages like if message is empty not shown the pop up ? Is it possible? Please help on this.
Thanks,
Faizeal
Hi Mark,
Having the same issue someone else mentioned earlier where terms and conditions dialog tries to load when the login screen is hit and just hangs and indicates it’s loading preventing the ability to login. Any ideas why it’s calling the UI page prior to login?
Thanks,
Sarah
Hi Mark,
First of all this is really handy thank you.
However I have one issue with it. We get a constant loading page if the user is not already logged in.
Is there a way to delay this loading until the user has logged in.
We use the out of the box login screen not SSO.
Thanks,
Daryll
Hi Daryll. This solution uses ‘gs.isLoggedIn’ to determine if the user is authenticated or not and prevent this issue. You’ll see this in the ‘TermsAcceptance’ script include. It has worked in the past, but it looks like ‘gs.isLoggedIn’ isn’t returning a correct value any more. You’ll want to contact ServiceNow to see about a fix for ‘gs.isLoggedIn’.
Hi Mark,
I’m wondering if you have tested this on Geneva. I took your update set and installed on my developer instance and nothing happens when I log on. Nothing special in the logs either 🙁
With regards,
Göran
Nevermind that question, It’s working now. I think it was another of my test ui script that stopped somehow this as well..
Thou another problem happens, I got the same problem as daryll above. It hangs at the loading screen… problem is, how can I now turn it off… since I cant log in…;(
Hi, to get it to work properly on Geneva I had to do the following to things:
a) change the load-function in the UI script, so the dialog is not trying to load on the login page by adding:
// if not logged in, don’t call
if (g_user.getUserName() == “guest”) {
return;
}
b) change the function getTermsAcceptanceFromSession so it does a string comparison with “TRUE”:
//If no terms acceptance display the dialog
if (answer != “TRUE”){
showTermsDialog();
}
Still there are some glitches, the dialog windows is displayed twice (the first time, it disappears againg after the home page starts to load). I’ll continue testing.
Thanks Julian! I’ve incorporated this into the download script.
Hi Mark,
Just what I was looking for to implement in our instance. However I had 1 small issue, is there a way to cancel the intervals, I just want users to accept the terms once. If a user already accepted it will not ask again ever.
I think all you would need to do is to set the terms acceptance property for frequency to a very large number of days.
Hi Mark,
I tried this on a developer instance however I’m having an issue when I changed the terms & condition messages. When I logout and tried to login to the instance again the login screen was replaced with the Terms & Condition dialog box, however the dialog box does not show any messages just a loading animation and there’s no Accept / Cancel.
No I can’t do anything with the instance and I’m forced to reset it. I’m now afraid to deploy it on my live instance.
You can check the error screenshot below in the link
https://drive.google.com/file/d/0BzYvxe7sPU3eMWt1X1NnUENqY3M/view?usp=sharing
Hi Mark,
Nevermind, I’ve use the fix Julian Hoch provided and it’s working now. I’m on Fiji by the way.
Thank you Julian Hoch for your solution.
We are running into an issue where this Terms box is appearing when exporting reports to PDFs. Has anyone seen this issue?