Display Pop-up terms and conditions on Login Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 12:45 AM
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.
Thanks,
- Labels:
-
Developer
-
ITSM: General
-
Service Portal
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 01:16 AM
Hi @Victor Mesa ,
I trust you are doing great.
Create a UI Page: Navigate to System UI -> UI Pages and click "New". Name the UI Page and add HTML code to display the login popup message.
Create a UI Script: Navigate to System UI -> UI Scripts and click "New". Add JavaScript code to handle the user's response to the popup message.
Create a UI Macro: Navigate to System UI -> UI Macros and click "New". Add the UI Page and UI Script to the macro.
Configure the Login Page: Navigate to System Properties -> System UI -> Login and add the UI Macro to the "Login Page Content" field.
Create a new table: Navigate to System Definition -> Tables and click "New". Name the table and add fields to store user responses.
Create a Business Rule: Navigate to System Definition -> Business Rules and click "New". Set the "When to run" field to "Before" and "Insert" and "Update" operations. Add JavaScript code to validate the user's response and insert or update the corresponding record in the new table.
Test the Login Popup: Log out of ServiceNow and log back in to test the login popup message and user response storage.
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 01:24 AM
Okay @Amit Gujarathi,
Could you tell me the code of that UI Page, UI Script, UI Macro and Business Rule ??
Thanks and best regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-13-2023 05:11 AM
@Amit Gujarathi, Please provide the snippet code how to implement below scenario
Hi I want to display popup message(not alert message) related to major incident information , when user login to ServiceNow display in classic UI homepage. Please help me with process and scripts.
my question --> https://www.servicenow.com/community/itsm-forum/after-user-log-in-into-servicenow-i-want-display-pop...
Ex. pop message:
Hi Stephen, Please look into the Major incident<incident link> opened by <caller name>.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-21-2023 01:35 AM
HI @Victor Mesa ,
I have implemented something around like this in my project .,
Please look into below scripts
UI Page Code
<!DOCTYPE html>
<html>
<head>
<title>Login Popup</title>
<style>
/* Add your custom CSS styles here */
</style>
</head>
<body>
<div id="login-popup">
<h1>Welcome to ServiceNow</h1>
<p>Please read and accept our Terms and Conditions before continuing.</p>
<input type="checkbox" id="agree-checkbox">
<label for="agree-checkbox">I agree to the Terms and Conditions</label>
<br><br>
<button id="submit-button">Login</button>
</div>
</body>
</html>
Client side code
function showLoginPopup() {
var modal = new GlideModal('login-popup');
modal.setTitle('Login');
modal.setWidth(400);
modal.setFooterButton('Submit', submitLoginPopup);
modal.render();
}
function submitLoginPopup() {
var agreed = document.getElementById('agree-checkbox').checked;
if (agreed) {
// Update user record with agreement status
var user = new GlideRecord('sys_user');
user.addQuery('user_name', g_user.getUserName());
user.query();
if (user.next()) {
user.terms_agreed = true;
user.update();
}
// Close the login popup and continue to the homepage
var modal = GlideModal.getByElement($('login-popup'));
modal.destroy();
window.location.href = gs.getProperty('glide.entry.homepage');
} else {
alert('Please agree to the Terms and Conditions to continue.');
}
}
// Show the login popup when the page loads
addLoadEvent(showLoginPopup);
Was this answer helpful?
Please consider marking it correct or helpful.
Your feedback helps us improve!
Thank you!
Regards,
Amit Gujrathi