
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2021 12:08 AM
Hi All,
I am want a popup every time I login to the instance. I know here , it is achieved for standard ui, but there are cases that end users when login to the instance are directly redirected to service portal, hence there I need similar popup as well.
This popup should be of confirm box type with two buttons "OK" and "Cancel"
If user selects cancel , he/she should be logged out.
I followed below steps to achieve this :
1. Created a widget
2. Added the widget to the /sp index page through page designer
Widget client script is following
function(spModal) {
/* widget controller */
var c = this;
spModal.open({
title: 'Info',
message: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.<p>
<p>Click the OK to proceed. If clicked Cancel you will be logged out',
buttons: [
{label:'Cancel'},
{label:'Ok', cancel: true,primary: true}
]
}).then(function(){
location.href='/logout.do';
})
}
Widget works perfectly, I need to just make it load/pop up only when user logins not evry time I visit the serviceportal homepage.
Solved! Go to Solution.
- Labels:
-
User Interface (UI)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-02-2021 12:35 AM
Hello All,
I was able to find correct way to achieve my requirement, thanks to
I am attaching my solution screenshot of widget for your reference. Also I have highlighted key points which were crucial for the solution to work.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2021 12:44 AM
Add your code in script include SPEntryPage().getFirstPageURL().
So that it runs only first time.
Please see below documentation
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0746730
Hope this helps.
Regards,
Ujjawal

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2021 12:56 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2021 01:17 AM
You need not to create a separate widget. You need to add your logic to script include itself.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2021 01:39 AM