Catalog Client Script not setting the reference variable using URL parameter (value keeps reverting)

SwethanaB
Mega Contributor

Hi team,

I’m working on a Catalog Client Script (onLoad) where I need to populate a reference variable (configuration_item) based on a URL parameter ci=1.

 
OnLoad script:

function onLoad() {
    var ci = g_form.getParameter('ci');
    g_form.clearValue('configuration_item');
    if (ci === '1') {
        g_form.setValue('configuration_item', 'sys_id');
    }
}
 
The variable still loads the previously used value, even after clearValue().
6 REPLIES 6

yashkamde
Kilo Sage

Hello @SwethanaB ,

 

try this script :

function onLoad() {
   var ci= getParameterValue('ci');
   if(ci == '1'){
      g_form.clearValue('configuration_item');
      g_form.setValue('configuration_item','sys_id');
   }
}
 function getParameterValue(name) {
        var url = top.location.href;
        var value = new URLSearchParams(url).get(name);
        if (value) {
            return value;
        }
    }

 

If my response helped mark as helpful and accept the solution.

Also ensure catalog client script > ui type is set to -> ALL 

Screenshot 2026-02-25 140437.png