NetSuite Tricks

I've been administrating and coding in NetSuite for years. Very often I'll hit some obscure bit of script that solves a problem.

Then... I lose it, can't bookmark it, or the site I found it goes under.

Solution: I'm posting the code here for everyone else to find, as a way of giving back to the global NetSuite community.

You're welcome.

Tips and Tricks Archive

Now moved to Troy's NetSuite Tips 'n Tricks.docx 

SuiteScript Tricks

How to selectively modify a Multiple Select field in SuiteScript 2.x 

Problem: I created a Multiple Select custom field on our Order Confirmation transaction record to track various statuses of multiple automations. I needed to set/unset individual values without overwriting everything in the field. However, SuiteScript 2.x getValue() of a multi-select field does not return an array of values: it returns a string which is delimited by the '\u0005' Unicode character.

Why? No idea, but it's certainly counter intuitive.

Discovery: After getValue(), check util.isString(yourValue) first; if true, then yourValue.split('\u0005') will provide the more intuitive array value. If the value is not a string it may be an empty array. I say "may" because in my code, assuming it was an empty array if not a string actually worked.

Solution: I created a function with 2 parameters: values to set, and values to un-set, provided  as comma-delimited strings. From a workflow I can call this workflow function as needed to set/unset values in the multi select field.

Code: NetSuite SuiteScript - workflow action script demonstrating Multi Select field manipulation