Maximiliano
12/04/2023, 10:42 PMif (itemTypeRecordType) {
var itemObj = record.load({
type: itemTypeRecordType,
id: itemId,
isDynamic: true
});
var locationQuantityAvailable = itemObj.getCurrentSublistValue({
sublistId: 'locations',
fieldId: 'locationquantityavailable'
});
}erictgrubaugh
12/04/2023, 11:05 PMlocationquantityavailable
is not a field on the Inventory Item record; you can determine that by noting it is not listed in the Records Browser. It is instead a Search Column in an Item search. Instead of loading the record, you'll want to perform a search via N/search
Maximiliano
12/04/2023, 11:15 PMerictgrubaugh
12/05/2023, 2:21 AMinventorylocation
. Here's a 2.0 example straight out of my old cookbook:
require(["N/search"], function (s) {
s.create({
type: s.Type.INVENTORY_ITEM,
filters: [
["inventorylocation", s.Operator.ANYOF, ["4"]], "and",
["locationquantityonhand", s.Operator.ISNOTEMPTY, ""]
],
columns: [
{name: "displayname"},
{name: "locationquantitybackordered"},
{name: "locationquantityonhand"},
{name: "locationquantityonorder"}
]
}).run().getRange({start: 0, end: 10}).forEach(printOrder);
function printOrder(result) {
console.group(result.getValue({name:"displayname"}));
console.log("On Hand: " +
result.getValue({name:"locationquantityonhand"})
);
console.log("On Order: " +
result.getValue({name:"locationquantityonorder"})
);
console.log("Backordered: " +
result.getValue({name:"locationquantitybackordered"})
);
console.groupEnd();
return true;
}
});
erictgrubaugh
12/05/2023, 2:23 AM