Livio
10/25/2023, 12:51 PMMatt Carter
10/25/2023, 1:26 PMLivio
10/25/2023, 1:28 PM/**
*@NApiVersion 2.x
*@NScriptType UserEventScript
*/
define(['N/search', 'N/record', 'N/runtime', 'N/file', 'N/format', 'N/log'],
function(search, record, runtime, file, format, log) {
function FindItemRecord(context) {
var newRecord = context.newRecord;
var item_name = newRecord.getValue({
fieldId: 'custrecord111'
});
try {
log.debug('item_name', item_name);
var inventoryitemSearchObj = search.create({
type: "inventoryitem",
filters: [
["type", "anyof", "InvtPart"],
"AND",
["name", "is", item_name]
],
columns: [
search.createColumn({
name: "internalid",
label: "Internal ID"
}),
search.createColumn({
name: "itemid",
label: "Name"
})
]
});
var results = inventoryitemSearchObj.run();
var resultsRange = results.getRange(0, 1);
if (resultsRange.length > 0) {
var item_internal_id = resultsRange[0].getValue({
name: "internalid",
label: "Internal ID"
});
}
log.debug('item_id', item_internal_id)
newRecord.setValue({
fieldId: 'custrecord_pic_request_item',
value: item_internal_id
});
} catch (error) {
log.debug("error", error);
}
}
return {
beforeSubmit: FindItemRecord,
};
});
Matt Carter
10/25/2023, 1:33 PMLivio
10/25/2023, 1:36 PMMatt Carter
10/25/2023, 1:43 PMLivio
10/25/2023, 2:02 PMLivio
10/25/2023, 2:03 PMMatt Carter
10/25/2023, 2:26 PMLivio
10/25/2023, 2:27 PMLivio
10/25/2023, 2:28 PMMatt Carter
10/25/2023, 2:29 PMLivio
10/25/2023, 2:30 PMMatt Carter
10/25/2023, 2:34 PMLivio
10/25/2023, 2:34 PM