It would still be handy to know how to de-dupe arr...
# suitescript
k
It would still be handy to know how to de-dupe arrays of objects. I tried the following but apparently SS2.1 doesn't have findIndex
b
if you really wanted to do it on an object, you probably want the related
uniqBy
k
How would I do it in native javascript? I'd rather not need to get an unfamiliar external library working in NetSuite since this project is due today. >.<
b
lodash is a very well known library
it has a whole family which has taken over the _ global
k
I know it's well known, but I don't have time to learn it today. 😄
I'm aware it's much beloved by the people who use it, and I do plan to get around to it some day, just not today. 🙂
b
basics is to make a new array and an object (sets, array, or objects depending on your performance needs) to keep track of elements you have seen before
add elements to your new array and then put it into your seen tracker
dont add an element to your new array if its in your seen tracker
for your code, you really want to be careful about using stringify so many times, its not a cheap operation
k
yeah that was just an example off the interwebs
I guess I could just crawl through the whole array of objects one property at a time
b
its more that its more efficient to call json.stringify once on each element on the array
rather than stringifying each element every time you do a comparison
its one of those things that leads to poor scaling as array length increases (O(N^2))
k
Ugh, I'm so confused by the Analytics engine. It makes no sense...
In my Analytics dataset I get two results for the same internal ID
one localized, one not
same query in SuiteQL gets over 5000 results
one for each possible combination of subsidiary, currency, etc
but the record itself doesn't have a currency selected...
Why would the dataset in the UI return a different result set than SuiteQL?
b
whats the query used by the dataset?
k
modifying the query to SELECT DISTINCT cuts it down from over 5000 to around 100
the dataset is a big long xml file, not sure how to trim it down into SQL for pasting here
b
k
Oooh good idea >.<
🤦‍♂️
Wow that's some ugly SQL
Untitled
b
you can ignore the columns
you want to pay attention to how the join is done
copy however netsuite does the join to get similar rows to what the dataset gets
💯 1
👍 1
k
Good call
PERFECT!!! 😄
Thank you thank you thank you! 😄
Once I copied the way NetSuite did the join, I got identical results
2 rows, not 5000+