- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 10:47 PM
Can anyone help me @Ankur Bawiskar @Sandeep Rajput @Dr Atul G- LNG @Vasantharajan N
as I want to show URL link in field message when option is selected in dropdown list on catalog item.
As when the User select Add Modify Access from the drop down list
Below type message should appear along with the URL link in the last
tried with Catalog UI Policy and OnChange Client Script as mentioned below but URL link is not visible.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(g_form.getValue('my_telephony_issue_is_about>') == '<add_modify_access>'){
var url = 'https://uat.service-now.com/uat_sp?id=sc_cat_item&sys_id=4ffe2590db4a73005841e3334a9619ed&sysparm_category=34bb6f54db650740f91e7aecbf961929';
g_form.addInfoMessage('href=' + url + ' target="_blank"');
}else{
g_form.clearMessages();
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 11:35 PM
@Arjun Reddy Yer - The below code sample use DOM manipulation to show the field message. So make sure Isolate script is set to false in your client script and update the following in the below code
- Condition
- Variable sys_id
- Field message and url link
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'No') {
var url = 'https://mylink.to.cataog/form';
g_form.showFieldMsg("approvals", "this will be removed"); // this field msg will be overwritten by the below DOM manipulation code
var variable_sys_id = "eedbb8b247ca3110b3b3b477536d4340"; //Variable sys id in which we need to display the message.
var x = gel('IO:'+variable_sys_id+'_fieldmsg');
x.innerHTML = '<div class="fieldmsg notification notification-info">' +
"<p> <b> Available options </b> </p> "+
"<p> - Option A </p>"+
"<p> - Option B </p>"+
"<p><a href='" + url + "' target='_blank' >Link to form</a></p>" + '</div>';
} else {
g_form.hideFieldMsg("approvals");
}
Result of the above onChange client script
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 11:07 PM
Try below code
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if(g_form.getValue('my_telephony_issue_is_about>') == '<add_modify_access>'){ // Also check if the value has <>
var url = 'https://uat.service-now.com/uat_sp?id=sc_cat_item&sys_id=4ffe2590db4a73005841e3334a9619ed&sysparm_category=34bb6f54db650740f91e7aecbf961929';
g_form.addInfoMessage("<a href='" + url + "' target='_blank' >"); // Modified this
}else{
g_form.clearMessages();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 11:17 PM - edited 11-13-2023 11:31 PM
not showing anything
if(g_form.getValue('my_telephony_issue_is_about>') == 'add_modify_access'){ // The value is not having <>
var url = 'https://uat.service-now.com/uat_sp?id=sc_cat_item&sys_id=4ffe2590db4a73005841e3334a9619ed&sysparm_category=34bb6f54db650740f91e7aecbf961929';
g_form.addInfoMessage("<a href='" + url + "' target='_blank' >");
}else{
g_form.clearMessages();
}
}
it should show as below when user selected Add Modify Access in the dropdown list and user must able to click on the link and it should redirect to another page as mentioned in the link
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-14-2023 11:35 PM
@Arjun Reddy Yer - The below code sample use DOM manipulation to show the field message. So make sure Isolate script is set to false in your client script and update the following in the below code
- Condition
- Variable sys_id
- Field message and url link
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'No') {
var url = 'https://mylink.to.cataog/form';
g_form.showFieldMsg("approvals", "this will be removed"); // this field msg will be overwritten by the below DOM manipulation code
var variable_sys_id = "eedbb8b247ca3110b3b3b477536d4340"; //Variable sys id in which we need to display the message.
var x = gel('IO:'+variable_sys_id+'_fieldmsg');
x.innerHTML = '<div class="fieldmsg notification notification-info">' +
"<p> <b> Available options </b> </p> "+
"<p> - Option A </p>"+
"<p> - Option B </p>"+
"<p><a href='" + url + "' target='_blank' >Link to form</a></p>" + '</div>';
} else {
g_form.hideFieldMsg("approvals");
}
Result of the above onChange client script
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2024 09:17 PM
The code doesn’t work for portal.
Is there a way to work make this code work in portal as well.