How do I reference a value from the core_company table into a service catalog item?

hienlam
Kilo Contributor

Hi all,

I am looking for some help on referencing a value from another table to this catalog item. The screenshot below shows an example of me wanting to auto-populate the Billing ID of the company when the company name is filled. I have done this with ease on Call/Incident/Request forms but I have had no luck on a catalog item. Is there an easy way to do this or does this require a client script?

find_real_file.png

1 ACCEPTED SOLUTION

Ashok Kumar Am1
Giga Expert

Hi,



You need to create a on change client script to populated the related field value.


View solution in original post

5 REPLIES 5

Ashok Kumar Am1
Giga Expert

Hi,



You need to create a on change client script to populated the related field value.


Thanks. I figured it would have to go that route. Is it an on change client script against the catalog item or the variable set? What would the script look like?



The company field would be filled out with the company name (core_company.name) and the billing ID is also in the same table (core_company.billing_id).


You can create it on either catalog item or variable set.



code looks like below:



function onChange(control, oldValue, newValue, isLoading) {


Obj = g_form.getReference('company',setInfo);


}



function setInfo(Obj){


g_form.setValue('billing_id', Obj.billing_id);    


}



Use the correct variable names in the code


Thank you very much! I got it working as intended.