RE: Weird JSON/Saved Search Issue

I am building a script that uses a Search to collect the carton items from the Inventory Details for an Item Fulfillment

* @NApiVersion 2.1
* @NScriptType UserEventScript
define([‘N/record’, ‘N/log’, ‘N/search’ ], function(record, log, search) {
function beforeLoad(context) {

//Log our enteties
if(context.type === context.UserEventType.VIEW){
//Get the Fulfillment Record ID
var fulfillmentRecordID =;
log.debug(“Fulfillment Id”,fulfillmentRecordID);

var inventorydetailSearchObj = search.create({
type: “inventorydetail”,
search.createColumn({name: “pickcarton”, label: “Pick Carton”})

let inventorydetailSearchResults ={
start: 0,
end: 100

log.debug(“ID Search Results”,inventorydetailSearchResults)

const uniquePickcartons = [];

for(let i = 0; i < inventorydetailSearchResults.length; i++){
let item = inventorydetailSearchResults[i];





return {
beforeLoad: beforeLoad


When I log.debug item.values or item[“values”] I get a blank even though the Item JSON is

      recordType: "inventorydetail",
      id: "4172470",
      values: {
         pickcarton: "2"
RedHeadHunt Rookie Asked on December 28, 2023 in SuiteScript.
Add Comment
1 Answers

This is because the `item` variable is a `N/search.Result` instance. This is not the same thing as the `JSON` representation output by `JSON.stringify()` which the `log` methods use internally. In a `Result` instance, the properties are intended to be accessed via its `getValue` or `getText` methods.

I suspect what you want is

    item.getValue({ name: ‘pickcarton’ })

See also:

Beginner Answered on December 28, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.