If i use the getReference in client script it is not working as expected please find the Script

kranthi2
Tera Expert

Hi,

If i use the getReference in client script it is not working as expected please find the Script.

here if i select configuration item then location of the configuration item should be populate in the assignment group

 

 var ciRef=g_form.getReference('cmdb_ci', setLocation);
    function setLocation(ciRef){
        g_form.setValue('assignment_group', ciRef.location);
Please help me on the same.
3 REPLIES 3

Sagar Pagar
Tera Patron

Hi @kranthi2,

 

You can populate a fields available on referenced table and it should be same referenced table on your current form.

 

According to your scripts, You are going to populate CI Location [cmn_location] value into Assignment group [sys_user_group]. It won't be possible.

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow

Harish Bainsla
Tera Sage
Tera Sage

var ciRef = g_form.getReference('cmdb_ci', setLocation);

function setLocation(ciRef) {
if (ciRef && ciRef.location) {
g_form.setValue('assignment_group', ciRef.location);
}
}

Ankur Bawiskar
Tera Patron
Tera Patron

@kranthi2 

it seems your logic is wrong.

you are populating location of that CI to group field.

Please select correct field from CI record which holds group information

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader