The CreatorCon Call for Content is officially open! Get started here.

Popup Message after logging in to instance

ah16
Mega Expert

Hi,

Can you please provide steps to create popup window with a message after logging in to instance?

Similar like this one:  https://www.servicenowguru.com/system-definition/login-terms-conditions-dialog/

 

Thanks,

Ashraf

 

1 ACCEPTED SOLUTION

I have added a check so it will not run on login page. And changed to session variable so it will trigger each new login:

addLoadEvent(function () {
    var session = gs.getSession();
    if (session.getClientData('popup_triggered')) {
        return;
    }
    if ((window.name !== 'gsft_main') || (window.parent.document.URL.indexOf("login.do") > -1)) {
        console.log("Prevent popup in this window or on this page.");
        return;
    }

    session.putClientData('popup_triggered', 'true');


    //Ensure that we call the dialog for the correct frame
    if (window.frameElement) {
        if (window.frameElement.id == 'gsft_main') {
            showTerms();
        }
    }
    else if (!window.frameElement) {
        if (!$('gsft_main')) {
            showTerms();
        }
    }
});

View solution in original post

21 REPLIES 21

Willem
Giga Sage
Giga Sage

I checked and they are describing about the config and they didn't listed how to create one unless I missed.

Thanks, I see the link you have provided has the code. Where do you modify to call your UI page after login.

Can you try create a UI Script with the following:

UI Type Desktop

Global checked/true

addLoadEvent(function () {
    //Ensure that we call the dialog for the correct frame
    if (window.frameElement) {
        if (window.frameElement.id == 'gsft_main') {
            showTerms();
        }
    }
    else if (!window.frameElement) {
        if (!$('gsft_main')) {
            showTerms();
        }
    }
});

var showTerms = function() {
    var dialog = new GlideDialogWindow('terms_and_conditions_dialog'); //Render the dialog containing the UI Page 'terms_and_conditions_dialog'
    dialog.setTitle('Terms and Conditions'); //Set the dialog title
    dialog.setSize(600, 600); //Set the dialog size
    dialog.removeCloseDecoration(); //Remove the dialog close icon
    dialog.setPreference('cancel_url', 'catalog_home.do?sysparm_view=catalog_default'); //Set optional cancel redirect URL
    dialog.render(); //Open the dialog
}