for every item on your order, loop through the row...
# suitescript
b
for every item on your order, loop through the rows and count quantity
c
Best to get qty committed from a search otherwise I’m looping through every line item over and over again. Some sales orders are around 800 lines
b
Thats horrific, but you only need to loop once if you are willing to store the item counts
c
How would I do that? I’d need to look at index[0].id then do if id===id for every item
then if there’s match, I do total = item.qty + item.qty
b
That said, i would prefer doing the first thing I said and remember which lots are assigned. You would have to do it anyways if you are dealing with duplicate items
c
hmm
So yeah, keep track of each lot qty then minus the lot quantity by how much I just assigned
b
Yes
c
Need to store the lotnumber date too
have to allocate inventory based on earliest lot expiry date