Anyone ever seen this? "type":"error.SuiteScriptEr...
# suitescript
c
Anyone ever seen this? "type":"error.SuiteScriptError","name":"SSS_INVALID_API_USAGE","message":"Invalid API usage. You must use getValue to return the value set with setValue. ","stack":
b
basically what the error says
netsuite allows you to setValue or setText to set field values
c
The script does NOT use setValue so I assume something before my script has done that
b
you must use the matching getValue or getText to get that value
c
Copy code
var modelName = newRecord.getText('custitem_ms_model_name');
if (modelName) {
    modelName = modelName.replace(/\s+/g, '-').toLowerCase();
}
Copy code
newRecord.setText({
    fieldId: 'custitem_additional_product_tags',
    text: modelName
});
b
thats basically the most common cause
custitem_ms_model_name
was set via value, you must access it via getValue
c
Won't that get the internal ID of the list item?
b
yup
c
So I can't do my regex on that so I still need the text value
b
lookup its value
c
I'll do a search
b
occasionally you can do a suitebulder solution and have a text field that sources its value
c
Not clear why this is needed but that's an implementation detail of SS
b
its optimization related
c
Fair enough.
b
netsuite doesnt need to lookup the matching text
c
What's the point of getText then?
If I can't use it in this context
b
shared model, the record.Record object is used in places other than user event scripts
its better than ss1, which would return nothing and no error
maybe i misremembered the ss1 thing
r
ss1 if you do a getText, you get the Text
p
What makes it worse is that you can trip on this problem from a script that’s fired previous to the one you’re working on. If you don’t know about this error, that can make things a little confusing!