Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Auto Populate variable in catalog item

Alon Grod
Tera Expert

I have the field u_service_offering of type reference to service_offering table in my sc_cat_item table.

In my catalog item 'Software' I have the variable service_offering of type reference to service_offering table.

How can I auto populate the variable service_offering with the value of u_service_offering from the current cat item when creating a catalog service request? I tried to use this script but its not working:

function onLoad() {
  
  var currentCatalogItem = g_form.getReference('sys_id');

  var serviceOffering = currentCatalogItem.u_service_offering;

  g_form.setValue('service_offering', serviceOffering);
}

 

1 ACCEPTED SOLUTION

@Alon Grod 

 

Can you try this:

 

javascript:current.cat_item.u_service_offering

View solution in original post

4 REPLIES 4

Prince Arora
Tera Sage

@Alon Grod 

 

Open the variable and go the default value of it.

and mention the script as below:

PrinceArora_0-1683799888042.png

 

javascript:current.u_service_offering

If my answer solved your issue, please mark my answer as Correct & 👍Helpful based on the Impact.
 

@Prince Arora its not working

@Alon Grod 

 

Can you try this:

 

javascript:current.cat_item.u_service_offering

Manmohan K
Tera Sage

Hi @Alon Grod ,

 

Please refer to below link for details on how to use g_form.getReference()

https://www.servicenow.com/community/developer-forum/client-script-onchange-getreference/m-p/1463098

 

Regards,

Manmohan