Hi, I have creating a user events script and I wan...
# suitescript
b
Hi, I have creating a user events script and I want to retrieve the text from the field instead of the internal id related to the value retrieve. This is during record creation, so the record has not yet been saved. I am getting the error below. Does anyone have any pointers on how I can get the text from the field?
Copy code
{"type":"error.SuiteScriptError","name":"SSS_INVALID_API_USAGE","message":"Invalid API usage. You must use getSublistValue to return the value set with setSublistValue.
g
Instead of getSublistValue use getsublistText api
a
This is a known API limitation; as the error states: You can't use getText on CREATE. Generally, is a good practice to only use getText methods as your last resort and always try to use getValue.
b
My issue is I need to check all text values starting with "2", the actual ID of the value is irrelevant for my purposes.
a
You get the IDs, and then you make a search and create an object/map with ID <-> TEXT, then you do your thing.
b
OK, so only way is a long winded way... Get Values as I am doing now... then do a search to get the text of that value, see if text starts with "2" then validate data. Thanks for the advice! 🙂
a
You may not feel like it initially, but it is the best way. getText is not needed, and you are going to avoid many possible problems by staying away from it.
n
You could filter your search to include AND "myfield" "startswith" 2 Might save you some work, particularly if you can then do a quick upfront of checking if you have any results 😉