- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2016 08:59 AM
I'm thinking of doing a few things when a user logs in.
So I'm looking into ways of how to trigger this. I found this Help the Helpdesk - run when logging into ServiceNow
which seems pretty straight forwards and isn't many line of code to get it to work.
So I created a global ui script to test, but I cant get it to work. can anyone explain why or have any other idea how to make something run when user logs on?
This is my code, pretty much copied from the above thread.
CustomEvent.observe('user.login', test);
function test() {
alert("CAN YOU FEEL IT!");
}
And nada happens.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-16-2016 01:34 PM
I found a way to do it.
When this inside a global ui script I get the "alert".
addLoadEvent( function() {
if(window.frameElement){
if(window.frameElement.id == 'gsft_main'){
alert("Working?");
}
}
})
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-15-2017 01:00 PM
Hi Goran - thanks for getting back with me. I was able to make it work as follows:
addLoadEvent( function() {
if(!g_user.hasRole("admin") && g_user.hasRole("itil") && window.frameElement && window.frameElement.id == 'gsft_main'){
if (window.frameElement.src.indexOf('welcome.do') > 0){
alert("YUUUP");
}
}
});
for some reason, the extra role check prevents it from popping up on logOUT as well...not sure why.
I still wish I could find a way to do this with a Installation Exit..absolutely no luck with that.
