Join us Dec. 16 for The Community Hour, our first global virtual User Group event!

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

SwethanaB
Tera 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().
7 REPLIES 7

@SwethanaB 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct ✅ and close the thread 🔒— this helps future readers find the solution faster! 🙏

yashkamde
Tera 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