Brian Rivera
ServiceNow Employee
Options
- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 10-26-2022 11:54 AM
Posting this simple solution here. Seen a lot of requests for the OTP Email to be sent out automatically when users are logging in to ServiceNow
UI Script - AutoEmailOTP
addLateLoadEvent(function(){
setTimeout(function(){
var windowLoc = top.window.location;
console.log('validating window..,');
if(windowLoc.href.includes("validate_multifactor_auth_code")){
console.log('window validated, triggering onClick...');
multifactorSendOneTimePassword();
}
}, 1000); //1 second delay
});
Notes:
- Feel free to remove the console.log() lines
- The 1 second delay is necessary to allow window.location.href to change from "navpage.do" to "validate_multifactor_auth_code.do". This may need to increase if some users have particularly slow browsers/PCs.