- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2024 08:14 AM
If the user selects a particular Business service (reference field) in the incident record producer, it should redirect to it's specific record producer or catalog form.
Business service field refers to the cmdb table. In the cmdb table, we have an attribute that holds the sys id of its dedicated record producer/ catalog form.
We have used onchange client script to redirect and script include to retrieve the sys id of the record producer from the cmdb table.
client script:
Script include: client callable is enabled
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2024 09:29 PM - edited ‎07-23-2024 09:30 PM
i hope from server side your getting sys_id of item that you need to redirect whenever there is change in Reference variable.
instead of "window.location.href " use this "top.window.location"
For reference
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var retrieveUrl = new GlideAjax('GetLocationsByRegion');
retrieveUrl.addParam('sysparm_name', 'getrecprodid');
retrieveUrl.addParam('sysparm_busc', newValue);
retrieveUrl.getXMLAnswer(function(response) {
if (response) {
var dataUn = JSON.parse(response);
var retUrl = dataUn.url;
if(retUrl){
top.window.location = 'https://dev####.service-now.com/sp?id=sc_cat_item&sys_id=' + retUrl;
}
else {
alert('No URL found for the given business service.');
}
}
});
}
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-23-2024 09:29 PM - edited ‎07-23-2024 09:30 PM
i hope from server side your getting sys_id of item that you need to redirect whenever there is change in Reference variable.
instead of "window.location.href " use this "top.window.location"
For reference
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var retrieveUrl = new GlideAjax('GetLocationsByRegion');
retrieveUrl.addParam('sysparm_name', 'getrecprodid');
retrieveUrl.addParam('sysparm_busc', newValue);
retrieveUrl.getXMLAnswer(function(response) {
if (response) {
var dataUn = JSON.parse(response);
var retUrl = dataUn.url;
if(retUrl){
top.window.location = 'https://dev####.service-now.com/sp?id=sc_cat_item&sys_id=' + retUrl;
}
else {
alert('No URL found for the given business service.');
}
}
});
}
Please mark helpful & correct answer if it's really worthy for you.
Thanks,
BK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2024 04:11 AM
Thank you! I have tried the above modified script it is working.