1) I'm trying to loop through my saved search on l...
# suitescript
m
1) I'm trying to loop through my saved search on line 34 (but it's not doing that) not sure if we can loop inside the run().each - 2) I am trying to keep total of quantities from the available quantities column in the search - would it work with the way I have it using line 36/61?
b
your loop is weird, it doesn't use the variable i. It also does not appear to use proper sublist patterns since I don't see where the items are selected. I might be able to tell you more, but its hard to give code advice without knowing what search_item_count is and what sort of items you are dealing with (lots, bins, serial numbers, etc)
m
at the moment i am just looking at lot/assembly items. what's the sublist pattern? the search_item_count is used to get the number of records found in a saved search. basically, i am trying to replicate the functionality whereby you add inventory details on a line on say a sales order.
if the quantity on the line is 10, upon adding inventory details - the available quantity for a serial/lot might be 5, therefore we'd add 5 and then select the next serial/lot number and see if there are 5 more available quantities free to use
b
When working with records in dynamic mode: Record.selectLine(options) or Record.selectNewLine(options) Record.setCurrentSublistValue(options) Record.commitLine(options)
when working with records in static mode: Record.setSublistValue(options)
when working with sublists, you need to specify which line you are working on, either through one of the line selection methods, or via the line option
on line 4, you probably don't want to run the search again. Use the ResultSet you used to set search_item_count
your for loop exit condition is probably wrong. there are 2 conditions to exiting the loop: running out of search results or if the total_committed is larger than the sales order line item's quantity committed
On line 52, the quantity is supposed to be the smaller of search_inventory_available or (sales order quantity committed - total_committed)
You don't want to set more quantity than was committed
on line 61, you probably want to add whatever value was set on the quantity to total_committed instead of set it.
be careful if you can have duplicate items on lines, the logic you wrote will not be safe
m
what i wrote so far is so messy - it's getting very confusing
i noticed i accidentally deleted the selectNewLine. also, the samples i saw didn't require it to have a line parameter
b
selectNewLine doesn't need the line, its always assumed the line is the one at the end