popup window once user login
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 01:23 AM - edited 03-28-2024 01:33 AM
Hello Experts,
I have a requirement to show popup window once user with a specific role login.
Have written below script, but it didn't work, can you please help me here?
UI Script: Global
UI Page:
HTML:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 10:24 PM
Hello @KarankiS,
Please refer to the below link's:
https://www.servicenow.com/community/developer-articles/create-a-popup-message-on-login/ta-p/2305530
https://www.youtube.com/watch?v=KPDRG2fzc9M
Mark my correct and helpful, if it is helpful and please hit the thumbs-up button to mark it as the correct solution.
Thanks & Regards,
Abbas Shaik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2024 11:02 PM
Hi @KarankiS
The script you provided seems mostly correct, but there might be a couple of issues that need addressing. Here's a revised version of your code with some adjustments:
UI Script (Global):
var ga = new GlideAjax('ClientUtil');
ga.addParam('sysparm_name', 'validateUserRole');
ga.getXML(showResponse);
function showResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == "true") {
var gdw = new GlideDialogWindow('test_window');
gdw.setTitle('Popup Title'); // Set the title of the popup window
gdw.setSize(750, 350);
gdw.render();
}
}
HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<p>
<span> #alert message</span>
</p>
<button class="btn btn-primary" onclick="ok()">OK</button>
</j:jelly>
Client Script:
function ok() {
GlideDialogWindow.get().destroy();
}