Tim_Pedersen
11/01/2021, 10:00 PMTim_Pedersen
11/01/2021, 10:00 PMdefine(['N/currentRecord', 'N/ui/dialog', 'N/log', 'N/search'], function(currentRecord, dialog, log, search) {
/**
*@NApiVersion 2.0
*@NScriptType ClientScript
* created by Tim Pedersen Nov 1 2021
* Things needing work
* 1) I cannot get the search to perform correctly. I get this error in the logs - "TypeError Cannot read properties of undefined (reading 'getValue')"
*/
function pageInit(context) {
var rec = currentRecord.get(); // create a variable/nickname for reference this record later on in the code
var itemId = rec.getValue({ fieldId: 'internalid' })
var searchResults = search.create({
type: search.Type.INVENTORY_ITEM,
filters: [
["type", "anyof", "InvtPart"],
"AND", ["internalid", "anyof", itemId],
"AND", ["inventorylocation", "anyof", "OIT Warehouse"]
],
columns: [
search.createColumn({ name: "itemid", label: "Name" }),
search.createColumn({ name: "inventorylocation", label: "Inventory Location" }),
search.createColumn({ name: "locationquantityonhand", label: "Location Quantity On Hand" }),
search.createColumn({ name: "locationpreferredstock", label: "Location Preferred Stock" }),
search.createColumn({ name: "locationreorderpoint", label: "Location Reorder Point" })
]
});
var result = searchResults[0]
var qoh = result.getValue({ column: "locationquantityonhand" });
var prefStock = result.getValue({ column: "locationpreferredstock" });
var reorderPoint = result.getValue({ column: "locationreorderpoint" });
log.debug({
title: 'Item ID is - ',
details: itemId
})
log.debug({
title: 'QOH for Line 0 is - ',
details: qoh
})
log.debug({
title: 'Pref Stock for line 0 is - ',
details: prefStock
})
log.debug({
title: 'Reorder Point for Line 0 is - ',
details: reorderPoint
})
return true
}
return { // this tells NetSuite when to run each script that we created above.
pageInit: pageInit, //pageInit is an event that fires whenever the page is loaded
}
});battk
11/01/2021, 10:05 PMTim_Pedersen
11/01/2021, 10:18 PMbattk
11/01/2021, 10:18 PMbattk
11/01/2021, 10:18 PMMichael Ponticello
11/01/2021, 11:17 PMMichael Ponticello
11/01/2021, 11:18 PMMichael Ponticello
11/01/2021, 11:20 PM