Zurich pop-up after user login with last login time

Sergio Ibanez
Tera Contributor

Hello community,

I have been reviewing internet info buy actually I cannot activate a pop-up with the last login time (one per session), after user successful login. I have used client scripts, UI script, ... 

The codes I have found are not working and if I run a "run point scan" I can see that GlideEncrypter, GlideCryptoService API and Encrypted API are deprecated.

Please, would anyone to be so kind to support me on how can achive this config that works in the actual and next Servicenow versions?

Thank you,

3 REPLIES 3

Tanushree Maiti
Kilo Patron

Hi @Sergio Ibanez 

 

Check if you are looking for this:

https://www.servicenow.com/community/developer-forum/why-pop-up-does-not-come-up-when-user-login/td-....

 

 

Please mark this response as Helpful & Accept it as solution if it assisted you with your question.
Regards
Tanushree Maiti
ServiceNow Technical Architect
Linkedin:

GlideFather
Tera Patron

Hi @Sergio Ibanez,

 

as per the official docs GlideEncrypter - Global (deprecated) it is recommended to proceed with Key management Framework to encrypt

 

let me know if it covers your question, the screenshot is not possible to read..

_____
100 % GlideFather experience and 0 % generative AI

Nishant_Shelar
Tera Expert

Hi @Sergio Ibanez 

This requirement doesn’t need any of the deprecated APIs like GlideEncrypter or GlideCryptoService.

You can achieve it using the last_login_time field from sys_user and a small session-based check.

  1. Get last login time
  • The value is already available in sys_user.last_login_time


2. Show popup only once per session

Script Include (Client Callable)

var GetLastLogin = Class.create();
GetLastLogin.prototype = Object.extendsObject(AbstractAjaxProcessor, {

    getLastLogin: function() {
        var user = gs.getUserID();

        // Check session flag
        if (gs.getSession().getProperty('shown_last_login') == 'true') {
            return '';
        }

        gs.getSession().putProperty('shown_last_login', 'true');

        var gr = new GlideRecord('sys_user');
        if (gr.get(user)) {
            return gr.last_login_time.getDisplayValue();
        }

        return '';
    }

});


Client Script (e.g., onLoad in UI / Portal)


var ga = new GlideAjax('GetLastLogin');
ga.addParam('sysparm_name', 'getLastLogin');
ga.getXMLAnswer(function(response) {
    if (response) {
        alert("Your last login was on: " + response);
    }
});



  • This ensures the popup shows only once per session
  • No dependency on deprecated APIs