How to display hyperlink on catalog form using client script

mounika58
Mega Expert

In the below script when condition is "No" I want to display a hyperlink on the catalog form so user can click on that link.

function onChange() {    

if (g_form.getValue('variables.owner') == 'Yes')

  {

          //g_form.setDisplay('variables.message',true);

          g_form.setDisplay('variables.Name',true);

          g_form.setDisplay('variables.Type',true);

                             

    }

else if(g_form.getValue('variables.owner') == 'No')

  {

        g_form.setDisplay('variables.Name',false);

        g_form.setDisplay('variables.Type',false);

        var info = 'Link: <a href="catalog_home.do?sysparm_view=catalog_default">Link</a>';

          //g_form.addInfoMessage(info);

            //g_form.showFieldMsg('owner',info);

         

                    }

}

But i am not able to do that using showFieldMsge.. Can you please give some suggestions

1 ACCEPTED SOLUTION

bernyalvarado
Mega Sage

Try something like the following:



1) Create a UI page and lets call it Link. Your UI page just need to have the following on its html field:


<a href="catalog_home.do?sysparm_view=catalog_default">Link</a>



2) Create a catalog variable of type UI Page and reference your recently created UI page Link



And voila!



Thanks,


Berny


View solution in original post

9 REPLIES 9

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hi Mounika,



You should not use variables prefix at client script i.e           g_form.setDisplay('variables.Name',true); should be g_form.setDisplay('Name',true);


Also please go through the below thread related to hyperlinks info.


https://community.servicenow.com/thread/148121


https://community.servicenow.com/thread/166958


Hi Pradeep,



Even with variables prefix script is working fine. But as suggested by you i have removed it.


bernyalvarado
Mega Sage

Hi Mounika,



One way you could do this is through a UI page.



Thanks,


Berny


bernyalvarado
Mega Sage

Try something like the following:



1) Create a UI page and lets call it Link. Your UI page just need to have the following on its html field:


<a href="catalog_home.do?sysparm_view=catalog_default">Link</a>



2) Create a catalog variable of type UI Page and reference your recently created UI page Link



And voila!



Thanks,


Berny