Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

DoD Warning Banner

mike1220
Kilo Explorer

Hello everyone.   I am a little new to this, so please excuse my inexperience.

I am trying to implement a DoD warning banner for my Service Now application.   I need the warning to be a pop up window when they hit the log in screen.   It should have two buttons, "OK" which will allow them to log in and "Cancel" which will redirect them to a page of my choosing.   I am not sure where to start on this.   Any help would be greatly appreciated.

Thanks,

Mike

5 REPLIES 5

tltoulson
Kilo Sage

Hi Michael,



Its been a while since I have seen one of those!   I have found this tutorial by Mark Stanger helps when doing a pop up like that.   The main difference is that instead of opening the dialog in an onLoad client script, you will likely need to display it in a Global UI Script.


Brad Tilton
ServiceNow Employee
ServiceNow Employee

You could try something like this in a global ui script:



CustomEvent.observe('user.login', addConfirmPage);



function addConfirmPage() {


  var msg = 'Show this message';


  if (confirm(msg)) {


      $('gsft_main').src = 'landing.do'


  }


  else {


      $('gsft_main').src = 'custom_page.do'


  }


}


That works great, but I have run into a little problem.   Since the user logs in before the banner appears, I want the "Cancel" button to log them out and send them back to the login page.   I have used the below code, but it just sends them back and they get the banner again which allows them to click "OK" and continue.   How do I log them out completely if they hit "Cancel"?



Thanks in advance for your help.



CustomEvent.observe('user.login', addConfirmPage);



function addConfirmPage() {


    var msg = 'Show this message';


    if (confirm(msg)) {


          $('gsft_main').src = 'home.do';


    }


    else {


          $('gsft_main').src = 'logout_redirect.do?sysparm_goto_url=<<my site>>/login.do';


    }


}




Brad Tilton
ServiceNow Employee
ServiceNow Employee

To log them out try:


$('gsft_main').src = 'logout.do';