- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 12:53 AM - edited 11-24-2023 12:55 AM
can you help me @Vasantharajan N
As I tried with below script URL is visible only for me remaining user it's not.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
if (newValue == 'No') {
var url = 'https://mylink.to.cataog/form';
var url = 'https:/un_sp?id=sc_cat_item&sys_id=73d9ec14db0de380fc597c57f49619df&sysparm_category=34bb6f54db650740f91e7aecbf961929' //my URL
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");
}
For Me:
For Other Users:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 06:33 AM
@Arjun Reddy Yer - Please find the updated script for your reference. Please make the necessary changes as per your variable names.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var portal = top.location.href;
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
if (portal.indexOf("servicecatalog_cat_item_view") == -1) {
showFmsg(); // Show field message on Service Portal
} else {
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 {
if (portal.indexOf("servicecatalog_cat_item_view") == -1) {
hideFmsg(); // Hide field message on Service Portal
}else{
g_form.hideFieldMsg("approvals");
}
}
function hideFmsg(){
var variable_name = 'approvals';
var eleId = 'sp_formfield_' + variable_name + '_fieldmsgs_container';
var approvalEle = top.document.getElementById(eleId);
approvalEle.innerHTML = '';
}
function showFmsg() {
//g_form.showFieldMsg("approvals", "Updated");
var variable_name = 'approvals';
var eleId = 'sp_formfield_' + variable_name + '_fieldmsgs_container';
var approvalEle = top.document.getElementById(eleId);
approvalEle.innerHTML = '<div ng-repeat="message in field.messages | unique: \'message\'" class="wrapper-xs r m-t-xs ng-binding ng-scope bg-info" ng-class="{\'bg-danger\': message.type == \'error\', \'bg-warning\': message.type == \'warning\', \'bg-info\': message.type == \'info\'}" style="">' +
"<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>';
}
}
Result in Service Portal
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 02:48 AM
@Arjun Reddy Yer - The script provided will work for the platform view not on the Service Portal / ESC. If it's to work on the service portal/esc then we need to make further change
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 04:20 AM
Can you please help me to get it work on Service Portal/ESC
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-24-2023 06:33 AM
@Arjun Reddy Yer - Please find the updated script for your reference. Please make the necessary changes as per your variable names.
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var portal = top.location.href;
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
if (portal.indexOf("servicecatalog_cat_item_view") == -1) {
showFmsg(); // Show field message on Service Portal
} else {
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 {
if (portal.indexOf("servicecatalog_cat_item_view") == -1) {
hideFmsg(); // Hide field message on Service Portal
}else{
g_form.hideFieldMsg("approvals");
}
}
function hideFmsg(){
var variable_name = 'approvals';
var eleId = 'sp_formfield_' + variable_name + '_fieldmsgs_container';
var approvalEle = top.document.getElementById(eleId);
approvalEle.innerHTML = '';
}
function showFmsg() {
//g_form.showFieldMsg("approvals", "Updated");
var variable_name = 'approvals';
var eleId = 'sp_formfield_' + variable_name + '_fieldmsgs_container';
var approvalEle = top.document.getElementById(eleId);
approvalEle.innerHTML = '<div ng-repeat="message in field.messages | unique: \'message\'" class="wrapper-xs r m-t-xs ng-binding ng-scope bg-info" ng-class="{\'bg-danger\': message.type == \'error\', \'bg-warning\': message.type == \'warning\', \'bg-info\': message.type == \'info\'}" style="">' +
"<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>';
}
}
Result in Service Portal
Thanks & Regards,
Vasanth