The `alias` is what `asMappedResults` uses as the ...
# suitescript
e
The
alias
is what
asMappedResults
uses as the
key
for a column in the result set
a
Hi Eric, thanks for the response. I guess there is no way to define the Alias in the UI. It was indeed the formula column that was causing the problem. I was trying to skip the route of having to script the query 😅 so our consultants can create the Dataset in the UI and just have the script consume it directly.
e
Ah yes I'm much less familiar with the UI
a
The script can still consume the data using the built-in iterator, but then again the
.values
returns a 1-dimensional array of values which I was trying to avoid because I have to access a specific value thru an index which was the problem with saved searches containing multiple formula columns of the same type.
s
One option when you have a 1-D array of values is to define an access structure, then you can use a readable constant instead of a number, to access the elements. If you are using SuiteScript 2.1, you can do even better by using array destructuring, which is both compact and human readable.
a
thanks @scottvonduhn for the input, really appreciate it. However, that's where the problem is to begin with using saved searches with multiple formula columns, we have to access it using indices, the N/query module 1-d array would also be troublesome accessing it via a hardcoded index, more often than not, fellow consultant change the arrangement the column of a saved search/analytics datasets, the value the variable is expecting to hold would now be different.
e
If a Script depends on a saved Query or Search, then that saved Query or Search should rarely - if ever - be changed in the UI. If a Query or Search is constantly being tweaked for varying displays, it's probably not suitable for a script. One copy should be made for display, and one to be used in script
s
Yes, if the search or workbook is defined in the UI (outside of the script) then unfortunately, you do lose control of it. In our account, we mark any saved search or workbook used by a script with a special SCRIPT USE suffix, and any changes to those searches have to go through change management, so that any necessary script changes and testing can be performed to account for those changes.
❤️ 1
@erictgrubaugh’s suggestion of having two copies, one clearly marked for script use, the other clearly marked for display, is a practice we use often. You can’t stop people with the right permissions from changing it, but they should really know better if they have that level of access