Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

popup window once user login

KarankiS
Tera Contributor

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

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.setSize(750350);
        gdw.render();
    }
}

UI Page:

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();
}

 

2 REPLIES 2

Abbas_5
Tera Sage
Tera Sage

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

Sohithanjan G
Kilo Sage

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();
}

 

 

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)