sublist.setSublistValue does not like empty string...
# suitescript
l
sublist.setSublistValue does not like empty string '' ? {"type":"error.SuiteScriptError","name":"SSS_MISSING_REQD_ARGUMENT","message":"Sublist.setSublistValue: Missing a required argument: options.value","id":null,"stack": sublist field type is TEXT. I'm running a search. some custom fields may return null values. I change null to empty string '' using ,
Copy code
var myfield= result.getText({ name: 'myfield' }) || '';
if there's a single space is ok. what do you guys use?
n
Does it not like null?
Copy code
var myfield= result.getText({ name: 'myfield' }) || null;
I think that's what i've used in the past, but now im doubting myself
l
oh well if it likes null, then I'm over thinking this by converting null to empty string. let me try...
n
Copy code
myField && sublist.setSublistValue({
    id: 'your_sublist_id',
    fieldId: 'your_field_id',
    line: 0,
    value: myField
});
Could also just have it skip setting the value if it doesnt exist. I think this would be the shorthand way to do it
l
Copy code
var myfield= result.getText({ name: 'myfield' }) || null;
this works. i guess the search returns empty string, I have to convert to null.
thank you Nathan
n
🫡
222 Views