why pop up does not come up when user login

Alon Grod
Tera Expert

Hi,

I have a requirement to raise a pop up when user login per session. The UI page functionality works fine but when the user login the pop does not come up

 

Screenshot 2023-07-28 at 10.49.28.png

Screenshot 2023-07-28 at 10.49.42.png

1 ACCEPTED SOLUTION

@Alon Grod To show popup after login page there are no suggested solutions. The only way is to create the global ui script and add the modal in that.

jaheerhattiwale_0-1690636545726.png

 

The issue with this approach is that the global ui script gets attached to all the pages we open in native ui. And the popup may open in all the pages.

 

So you need to restrict the popup to be visible only once using session. The functions putClientData and getClientData.

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

View solution in original post

12 REPLIES 12

@Alon Grod To show popup after login page there are no suggested solutions. The only way is to create the global ui script and add the modal in that.

jaheerhattiwale_0-1690636545726.png

 

The issue with this approach is that the global ui script gets attached to all the pages we open in native ui. And the popup may open in all the pages.

 

So you need to restrict the popup to be visible only once using session. The functions putClientData and getClientData.

 

Please mark as correct answer if this solves your issue.

Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

@Alon Grod Add the script like below

 

UI Script:

var ga = new GlideAjax('SessionUtil');
ga.addParam('sysparm_name', 'showTermsAndCondition');
ga.getXML(showResponse);

function showResponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer == "true") {
var gdw = new GlideDialogWindow('terms_and_condition');
gdw.setTitle('Test');
gdw.setSize(750, 300);
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">
<div>terms and condition</div>
<g:dialog_buttons_ok_cancel ok="return ok()" cancel ="return cancel()"/>
</j:jelly>

 

UI Page Client Script:

function ok() {
    var ga = new GlideAjax('SessionUtil');
    ga.addParam('sysparm_name', 'setTermsAndConditionInSession');
    ga.getXML(redirectAfterOk);
}
 
function redirectAfterOk(response) {
    var answer = response.responseXML.documentElement.getAttribute("answer");
    if (answer == "true") {
//Redirect here
        window.location.href = "/sp";
    }
}
 
function cancel() {
    GlideDialogWindow.get().destroy();
}
 
Script Include:
var SessionUtil = Class.create();
SessionUtil.prototype = Object.extendsObject(AbstractAjaxProcessor, {
 
showTermsAndCondition: function(){
if(this.getTermsAndConditionFromSession()){
return "false";
}
return "true";
},
 
getTermsAndConditionFromSession: function(){
var session = gs.getSession();
return session.getClientData("terms_and_condition_accepted");
},
 
setTermsAndConditionInSession: function(){
session.putClientData("terms_and_condition_accepted", true);
return "true";
},
 
    type: 'SessionUtil'
});
 
Please mark this also as correct answer if this solves your issue.
Please mark the answer as correct or helpful based on impact
ServiceNow Community Rising Star, Class of 2023

Hi @jaheerhattiwale currently the class Glide dialog window has been depricate d . Si, how to achieve this now . Pls suggest