How to Populate a Catalog Item Field (configuration_item) Using URL Parameters in ServiceNow?

deepakm29284933
Tera Contributor

How can I populate the configuration_item field on a ServiceNow catalog item by passing a parameter in the URL? I want the field to auto-fill when the user opens the catalog item through a specific link.

If you want, I can also give you the exact script + URL format.

3 REPLIES 3

PradeepReddyA
Tera Guru

Hi @deepakm29284933 

You can try this catalog client script 

 

function onLoad() {

    // Manually parse the URL parameters

    var test = getParameterValue('yourpaarmeter'); // Get the parameter  from the URL

    if (test) {

        g_form.setValue('varaiable_name", requestedItem);   

    }

function getParameterValue(name) {

    var url = top.location.href;

    var value = new URLSearchParams(url).get(name);

    return value ? value : '';

}

}

Hope that Helps!

Huynh Loc
Mega Sage

Hi @deepakm29284933 
Please refer to the link below for detailed guidance on how to populate catalog variable values from a URL in ServiceNow:
https://snprotips.com/setting-catalog-item-variables-from-url/

If you find this response helpful, please consider marking it as Correct and Helpful. You may select more than one reply as an accepted solution.