How set list of reference type field's value

TT3
Kilo Guru

I have a table with column type of "List" which refers to another table. I use below script to add some values by script but it is not working. I also tried with push but still not working.

FYI: u_list_service_id is a List type referring to another table.

var arr2 = [];
arr2.push('1ced6d77876f4950cb9fda4e3fbb35f8');
arr2.push('58ed6d77876f4950cb9fda4e3fbb35fd');

var orderItem = new GlideRecord('cmn_location');
orderItem.get('26b4b57f876f4950cb9fda4e3fbb3565');
orderItem.query();

if (orderItem.next()) {
    //orderItem.u_list_service_id = ['1ced6d77876f4950cb9fda4e3fbb35f8','58ed6d77876f4950cb9fda4e3fbb35fd'];
    orderItem.u_list_service_id = arr2
    //orderItem.u_list_service_id.push('1ced6d77876f4950cb9fda4e3fbb35f8');
    //gs.print(orderItem.u_list_service_id);
    orderItem.update();
}

 

1 ACCEPTED SOLUTION

Aman Kumar S
Kilo Patron

Try using

arr2.join(',');

 

Best Regards
Aman Kumar

View solution in original post

3 REPLIES 3

Aman Kumar S
Kilo Patron

Try using

arr2.join(',');

 

Best Regards
Aman Kumar

Working:

var arr2 = [];

arr2.push('123');
arr2.push('456');

var orderItem = new GlideRecord('cmn_location');
orderItem.get('26b4b57f876f4950cb9fda4e3fbb3565');
orderItem.query();

if (orderItem.next()) {

    orderItem.u_list_service_id = arr2.join(',');

    orderItem.update();
}

Awesome!

Glad that it worked out for you

Best Regards
Aman Kumar