Fill Catalog Variable Via URL

DylanB
Tera Guru

Hello, we have a requirement to fill in a variable on the Employee Center view of a catalog item via the URL. I know there are many posts about this topic but after reading them, I still do not understand what I need to do to get this to work. 

To explain the requirement fully, we have a catalog item to update business applications in ServiceNow. Quarterly via flow designer, an email is sent to the business application owner. That email contains a URL to the catalog item and we want the URL in that email to fill in the Application Name reference field of the catalog item with the business application. The Application Name reference field references the cmdb_ci_business_app table. 

2023-11-30 09_33_01-Update Business Application - Employee Center and 2 more pages - Work 2 - Micros.png

 

From the other posts I've read, the way to do this is to have a catalog client script as well as a URL containing the parameter of the variable you wish to fill. My knowledge of scripting is lacking, so any assistance with this is very appreciated!

1 ACCEPTED SOLUTION

My BAD. I missed to check UI TYPE to ALL on catalog client-script to make it run on all platforms, not only on Service Catalog.

 

HSB_0-1701365888041.png

 

 

After that once you update the sys-id of catolog item in below url with appropriate URL Params, it should work -

 

/esc?id=sc_cat_item&sys_id=$CAT-SYS-ID$&email=hsb&justification=thisistesting

 

Should work as it worked on my PDI. 

 

Do mark this response as CORRECT / HELPFUL as it would help others & will help me as well to keep writing.

View solution in original post

9 REPLIES 9

My BAD. I missed to check UI TYPE to ALL on catalog client-script to make it run on all platforms, not only on Service Catalog.

 

HSB_0-1701365888041.png

 

 

After that once you update the sys-id of catolog item in below url with appropriate URL Params, it should work -

 

/esc?id=sc_cat_item&sys_id=$CAT-SYS-ID$&email=hsb&justification=thisistesting

 

Should work as it worked on my PDI. 

 

Do mark this response as CORRECT / HELPFUL as it would help others & will help me as well to keep writing.

Awesome, that did the trick! I had set UI Type to All previously but I had too much info in my URL. This was the final one that ended up working. Thanks a ton for the help!

 

https://<instance>.com/esc?id=sc_cat_item&sys_id=b27fbf591b3e755051582023604bcb44&application=032272d6878d1510141243fd0ebb352a

That's great to hear. Cheers Mate 🙂

Hii @H S B  I am trying the same thing but I am not able to set the values   here is the modified code 

function onLoad() {
   var meetingid = getParameterValue('meetingid');
   var desc = getParameterValue('description');
   if(meetingid){
      g_form.setValue('meetingid',meetingid);
   }
   if(desc){
      g_form.setValue('description',desc);
   }
}
 function getParameterValue(name) {
        var url = top.location.href;
        var value = new URLSearchParams(url).get(name);
        if (value) {
            return value;
        }
    }                              and this is my url ----https://dev204017

rishay44
Tera Contributor

Hi Sir, I'm facing a issue with this link and code ...my fields are name and code

function onLoad() {
    g_form.addInfoMessage("client script running");
    var name = getParameterValue('name');
    var code = getParameterValue('code');
    if (name) {
        g_form.addInfoMessage(name);
        g_form.setValue('name', name);
    }
    if (code) {
        g_form.addInfoMessage(code);
        g_form.setValue('code', code);
    }
}

function getParameterValue(check) {
    g_form.addInfoMessage("inside callby");
    var url = top.location.href;
    var value = new URLSearchParams(url).get(check);
    g_form.addInfoMessage(value);
    if (value) {
        return value;
    }
}