I am attempting to iterate through the Line items ...
# suitescript
j
I am attempting to iterate through the Line items on a new Bin Putaway Worksheet. For some reason, I cannot seem to get the Line item data (Like the Item ID, Quantity, etc.). The binCount variable returns 500 (for the number of line items), but I cannot seem to get ahold of the Line data. Can anyone help me with how to get the internalID and quantity of each line? Here is my sample code:
Copy code
var binWorksheet = record.create({type: record.Type.BIN_WORKSHEET, isDynamic: true, defaultValues: true});
            binWorksheet.setValue({
                fieldId: 'subsidiary',
                value: '2'
            });
            binWorksheet.setValue({
                fieldId: 'location',
                value: '2'
            });
            var binCount = binWorksheet.getLineCount({sublistId: 'item'});
// binCOunt === 500 here.
            for (var i = 0; i < binCount; i++) {

                var item = binWorksheet.getSublistValue({
                    sublistId: 'item',
                    fieldId: 'item',
                    line: i
                });
// item === '' here.

                binWorksheet.selectLine({
                    sublistId: 'item',
                    line: i
                });
                var item = binWorksheet.getCurrentSublistValue({
                    sublistId: 'item',
                    fieldId: 'item'
                });
// item === '' here as well.
            }
Thank you for any advice!
b
tried it out myself with different location
works fine for me, though i dont have 500 items missing bins
j
Interesting. I just ran the whole loop, and found that the very last item in the list (index 499) returns the item, but all the rest are blank...
Maybe I can iterate through the list in reverse, setting each item, and it will work.
Thank you @battk for your help!
I am still stuck on my Bin Putaway sheet. When I iterate the list, only the very last item in the list shows up. I am able to go in, and set the inventory detail and save it, but really need this to work for all the items in the list. Any ideas why I cannot see anything else in the list?
I have learned that the script works just fine when deployed. It just won't work from a client.
b
Oh. I might have directed you to the suitescript supported records page had i known
It lists client script as unsupported for remote objects