Redirect user to external website on new tabe using onChange script but not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 10:14 PM
I am currently building a Catalog item and I want user to be redirected to an external website (e.g. Microsoft.com) if they select no in the group_hr variable question which is select box type. The goal is to not let them submit the form if they are selecting no in that variable. Below is my script but it is not doing anything when i tested. Please assist:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
// Check if the new value is 'no'
if (newValue == 'no') {
// Message with a clickable link
var message = 'Please click <a href="https://www.microsoft.com" target="_blank">here</a> to get more information about this access.';
// Show message
g_form.showFieldMsg('group_hr', message, 'info');
// Redirect
top.window.open = "https://www.microsoft.com/";
}
}
I have tried window.location.href for redirect but no luck. It's also not displaying any messages that's in the code.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 11:45 PM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2025 07:47 PM
Hope you are doing good.
Did my reply answer your question?
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-10-2025 03:32 AM
Thank you for marking my response as helpful.
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 10:40 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-09-2025 10:52 PM
Hi Shruti,
Thanks for the update but I am not sure what's wrong as it doesn't work. I have UI policy on that variable which I have deactivated and there appears to be no conflict but still. There's no response on the CI when I change the group_hr value to no.