Add link to Catalogue item

cuchi
Mega Guru

Hi all,

i hope everyone is ok at their end.

i have a catalogue item where users select a CI and the environment.

What i would like to achieve is to display a popup when a specific combination of CI and environment are selected.

i created a UI Policy to show the message which includes the link. However, the link is not generated dynamically, so when i move the update set to UAT or prod i include the right sys_id for the link.

 

current code is:

 

        var ga = new GlideAjax('global.xxxxxUtils');   //Scriptinclude
        ga.addParam('sysparm_name', 'getInstance'); //Method
        ga.getXML(getResponse);
   
   
    function getResponse(response){

        var insname = response.responseXML.documentElement.getAttribute("answer");
       
        if(insname =='xxxxxdev') {
           g_form.addErrorMessage("For ....... Test please <a href = 'https://xxxxxdev.service-now.com/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_c...'>Click Here.</a>");
        } else {
            if(insname =='xxxxxprod') {
                    g_form.addErrorMessage("For .... Test please <a href = 'https://xxxxxprod.service-now.com/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_...'>Click Here.</a>");
            } else {
                g_form.addErrorMessage("For .... Test please <a href = 'https://xxxxxuat.service-now.com/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_c...'>Click Here.</a>");
            }
        }
    }Regards,Max
1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@cuchi 

don't use instance name, the instance name will change in UAT and prod.

Instead use relative url i.e. use '/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4

    function getResponse(response){

 

        var insname = response.responseXML.documentElement.getAttribute("answer");
       
        if(insname =='xxxxxdev') {
           g_form.addErrorMessage("For ....... Test please <a href = '/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_c...'>Click Here.</a>");
        } else {
            if(insname =='xxxxxprod') {
                    g_form.addErrorMessage("For .... Test please <a href = '/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_...'>Click Here.</a>");
            } else {
                g_form.addErrorMessage("For .... Test please <a href = '/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_c...'>Click Here.</a>");
            }
        }

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

View solution in original post

1 REPLY 1

Ankur Bawiskar
Tera Patron
Tera Patron

@cuchi 

don't use instance name, the instance name will change in UAT and prod.

Instead use relative url i.e. use '/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4

    function getResponse(response){

 

        var insname = response.responseXML.documentElement.getAttribute("answer");
       
        if(insname =='xxxxxdev') {
           g_form.addErrorMessage("For ....... Test please <a href = '/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_c...'>Click Here.</a>");
        } else {
            if(insname =='xxxxxprod') {
                    g_form.addErrorMessage("For .... Test please <a href = '/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_...'>Click Here.</a>");
            } else {
                g_form.addErrorMessage("For .... Test please <a href = '/sp?id=sc_cat_item&sys_id=9754fbdadb9ab51064dfb1a5f39619e4&sysparm_c...'>Click Here.</a>");
            }
        }

If my response helped please mark it correct and close the thread so that it benefits future readers.

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