how to show URL link in field message when option is selected in dropdown list on catalog item

Arjun Reddy Yer
Tera Guru

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 

ArjunReddyYer_0-1699943603136.png

Below type message should appear along with the URL link in the last

ArjunReddyYer_1-1699943949930.png

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();
}
}

 

 

1 ACCEPTED SOLUTION

@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

VasantharajanN_0-1700033740927.png

 

 


Thanks & Regards,
Vasanth

View solution in original post

11 REPLIES 11

This is not working in portal. Is there any way to make it work in portal as well.

Ankur Bawiskar
Tera Patron
Tera Patron

@Arjun Reddy Yer 

in field message it's not supported.

you will have to use info message

check script shared by Vasu

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

tried with below script it's showing click option 

 if(g_form.getValue('my_telephony_issue_is_about') == 'add_modify_access'){
var url = '<a href="https://uat.service-now.com/uat_sp?id=sc_cat_item&sys_id=4ffe2590db4a73005841e3334a9619ed&sysparm_category=34bb6f54db650740f91e7aecbf961929" target="_blank">AIA</a>';
g_form.addInfoMessage(url);
}else{
g_form.clearMessages();

 it should show as with the message and at the last click option of the link should be there

ArjunReddyYer_0-1699947993462.png

but it's showing at the Top click option

ArjunReddyYer_0-1699948906002.png

 

 

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @Arjun Reddy Yer 

 

Experts already responded. It is not possible on field , but yes you can do in Info Message.

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************