how should we set a multi select field? it was ove...
# suitescript
m
how should we set a multi select field? it was overriding the existing value on the field. so then I tried setting the field with the existing and new value, but get this error:
Copy code
You have entered an Invalid Field Value null\u00059271228
var so_record = context.newRecord;
            var new_so_id = new Array();
            new_so_id = so_record.id;// NEW VALUE

var existing_so = case_update.getValue({
                fieldId: 'custevent_case_sales_order'
            }); //EXISTING VALUE

case_update.setValue({
                fieldId: 'custevent_case_sales_order',
                value: [existing_so, new_so_id]
            });
b
\u0005
is what is used internally as a separator for multi select fields
therefore your error suggests that existing_so is
null
and new_so_id is
9271228
m
Ah right so I'd need a separator. Would you say that's the correct approach, as in getting the existing values and resetting them or it's not required?
b
depends on the context, in my experience multi select fields are unreliable in client script
that said, your error is not that you are setting it wrong
its that you are trying to set null
setting multi selects with an array is how you are supposed to set it
your troubleshooting should consist of checking what value is in existing_so
fair chance it wont work if its not a string or a number
m
I'm trying to set it on afterSubmit. My existing so returns the internal id of the so and the type is object.
b
one of your assumptions is wrong
your line of thinking in this case should be why your existing so is an object
m
I was able to set the multi-select field without a separator: existing_so.push(new_so_id); the existing so type returns object, yet I was able to use an array function (push) on it. Seems a bit odd.
b
typeof [] === 'object'
m
ah right, fine