How to combine the saved search as objects of objects

Here the saved search results are combined based on the internal id.

   let itemReceiptData = {};

transferorderSearchObj.run().each(function (result) {                   

let temp = {};                   

temp.item = result.getValue({                       

name: “item”,                       

join: “applyingTransaction”,                       

label: “Item”                   

});                   

let itemReceiptInternalID = result.getValue({                       

name: “internalid”,                       

join: “applyingTransaction”,                       

label: “Internal ID”                   

});                   

temp.quantity = result.getValue({                       

name: “quantity”,                       

join: “applyingTransaction”,                       

label: “Quantity”                 

  });                   

temp.line = result.getValue({                       

name: “line”,                       

join: “applyingTransaction”,                       

label: “Line ID”                   

});                   

temp.itemWeight = result.getValue({                       

name: “custcol_jj_item_weight”,                       

join: “applyingTransaction”,                       

label: “Item Weight Per Quantity”                   

});                   

if (itemReceiptData[itemReceiptInternalID]) {                     

  itemReceiptData[itemReceiptInternalID].push(temp)                   

} else {                       

itemReceiptData[itemReceiptInternalID] = [temp]                   

}                   

return true;               

});               

return itemReceiptData;

Leave a comment

Your email address will not be published. Required fields are marked *