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

Cool...... Thank you so much Berny.


Hi Berny,



We will be able to do this using UI macros and formatters.


Which one is the best practice?


bernyalvarado
Mega Sage

It worked for me in a Fuji instance


Link.jpg


Thanks,


Berny


It worked for me as well. But that field is being displayed in all the choice list options i select. What should i be doing to make it visible only for one choice list option?


If you are creating a variable as per Berny's advise, then you should be able to hide it with g_form.