Just a thought, is there anyway to compute the tot...
# suitescript
t
Just a thought, is there anyway to compute the total/sum of a sublist items without looping through?
s
with NFT, summing the total quantity of items on a sales order is as simple as
Copy code
_.sum(salesorder.item, line=> line.quantity)
same idea for summing any other numeric field on the line.
I very rarely write any loops - they are error prone and not descriptive of their purpose without reverse engineering.
in contrast
_.sum
is very clear as to what it's doing, IMHO (well, and the opinion of thousands of other devs 🙂 )
w
@stalbert - curious, what does NFT stands for? and how do you get the salesorder.item object/prop? thanks so much
n
@wbermudo it stands for NetSuite Fasttrack Toolkit. https://github.com/ExploreConsulting/netsuite-fasttrack-toolkit-ss2
🔥 1
w
@stalbert - Got it. Thank you so much! really helpful.
t
Got it @stalbert thanks for the info 🙂