This doesn't seems correct. the sub_list is a fiel...
# suitescript
n
This doesn't seems correct. the sub_list is a field object in your code. What you need to actually do is getValue instead of getFields. Also, you don't need to assign new_sub_list the sub_list variable. instead, you should just declare it as an array using var new_sub_list = [];
m
thanks. so something like this? var item_record = record.load(currentRecord); var sub_list = item_record.getValue({ fieldId: 'subsidiary' }); var new_sub_list = [] for (var x in sub_list) { new_sub_list[x] } new_sub_list.push("4")
as subsidiary is string can we just pass internal id as string value?
n
for (var x in sub_list) { new_sub_list.push(x); }
It's okay to pass a number as well.
But I think it takes only string parameter so...
String it is : P
var item_record = record.load(currentRecord); var sub_list = item_record.getValue({ fieldId: 'subsidiary' }); var new_sub_list = []; for (var x in sub_list) { new_sub_list(x); } new_sub_list.push("4") item_record.setValue({fieldId: 'subsidary', value: new_sub_list};)
m
new_sub_list is not a function error
n
my bad. should be new_sub_list.push(x);
inside for
m
so code runs fine now without any error but my item's sub doesn't get updated with the new value...should we end using item_record.save(); or something else? thanks mate, just popping out for a bit!