Hi, I am new to Netsuite, writing me first client ...
# suitescript
g
Hi, I am new to Netsuite, writing me first client scripts and had a (should be) quick question - I am creating a popup upon adding an item to a sales order. I want to display avail qty in diff locations. I am able to get the item and qty like this var sItem = currentSO.getCurrentSublistText({type: 'item', fieldId: 'item', sublistId: context.sublistId});             var nQqty = currentSO.getCurrentSublistValue({type: 'item', fieldId: 'quantity', sublistId: context.sublistId}); how would I get the location (and qty per location) ?
b
do a search for your information
g
in the script i have to do a search? no other way?
Anyone have any suggestions for me?
s
Are you using bins?
Or Lot/Serial Numbers?
if No to those quesitons, In the record browser there is a field called search field locationquantityavailable you can try a search.lookupfeilds for that field. Not sure if that will give you what you want but worth a try
b
your primary options are to load the item record or to do a search on the item record to get the information you need
if you have an aversion to those options, you can customize the form to have location and quantity available at the item level
that way the available quantity shows the quantity at the line level
g
Thanks going to try
a
Guys, loading a scripted record on change of the item.... Will keep the UI freezed also using promises. With no big data scenarios / no heavy scripted records it could work.... You also have inventory locations count as a possible search so that you can perform the search for all items on the form and it will cost less
You need to tailor balance this kind of customizations. Do they have a lot of items / locations combinations? Otherwise loading the data you could need in before load and store the value in a long text as JSON will keep the UI really fast (1000 records, 1 search). But is not suitable in case you need "REAL Real time data". But again, choose the search approach instead of the load
g
THanks! This is what i ended up usnig
var itemRecord = record.load({ type: 'inventoryitem', id: 739 });
            var locationCount = itemRecord.getLineCount('locations');             var allLocInv = [];             for (var i = 0; i < locationCount; i++) {                 allLocInv.push({                     location: itemRecord.getSublistValue('locations', 'location', i),                     quantityavailable: itemRecord.getSublistValue('locations', 'quantityavailable', i)                 })             }
var itemRecord = record.load({ type: 'inventoryitem', id: 739 });             var locationCount = itemRecord.getLineCount('locations');             var allLocInv = [];             for (var i = 0; i < locationCount; i++) {                 allLocInv.push({                     location: itemRecord.getSublistValue('locations', 'location', i),                     quantityavailable: itemRecord.getSublistValue('locations', 'quantityavailable', i)                 })             }