Business Rule to populate the Field values From Another Field Through Reference Field

sekhar6
Tera Contributor

Hai,

Need a help in creating business rule. I am new to service now .kindly help on this script.

I Have an Customer Field On the form ,I have taken Reference table in Customer Field, If I Select The Customer Field, Display the Customer Name field and Multiplier Field  

image

 I Was Trying This Script ,Using Business Rule.

var gt = new GlideRecord('u_ln_customers');
gt.addQuery('u_ln_customers', current.u_customer);
gt.query();

 

if('u_customerISNOTEMPTY');
{}

 

if(gt.next()){}

 

current.u_ln_customers_u_customer_name =gt.u_customer.u_cname;

 

current.u_ln_customers_u_multiplier = gt.u_customer.u_multiplier;

image

 image

12 REPLIES 12

Thameem Ansari
Giga Guru
Giga Guru

hello there. i believe the u_customer field from the form is a reference to the u_ln_customers.so you should be querying for the sys id of that table.

 

then in the script line number 4 replace the query as below

gt.addQuery('sys_id',current.u_customer);

 

please mark my answer correct and helpful it it helps you in anyway

Regards,

Thameem

Hai ,

 Its Not Working,

 

 

Please answer the below questions. 

 

1.does the current.u_customer field is a reference field of the u_ln_customers table

2.if yes the u_cname and u_multiplier field are available in the same u_ln_customers  table or its from different table

 

hai ,

Yes both are available in same table,