In Netsuite, the Sales Order record type contains a field called "shipaddresslist" which contains the Customer Address Internal ID associated with the selected Customer Address.
Unfortunately, there is no search column for Sales Orders that will get the value of "shipaddresslist," so I had to find a workaround.
Using SuiteScript, I've been able to get the value of this field by looping through my search results, passing in the Sales Order ID to the record.Load() function, and calling record.getValue() on the loaded record, as shown below
Search:
var salesorderSearchObj = search.create({
type: "salesorder",
filters:
[
["type","anyof","SalesOrd"],
"AND",
["item.isfulfillable","is","T"],
"AND",
["status","anyof","SalesOrd:B","SalesOrd:E","SalesOrd:D"],
"AND",
["quantitycommitted","greaterthanorequalto","1"],
"AND",
["location","anyof","1","3"],
"AND",
["mainline","is","F"],
"AND",
["item.type","anyof","InvtPart"]
],
columns:
[
search.createColumn({
name: "transactionnumber",
sort: search.Sort.ASC,
label: "Transaction Number"
}),
search.createColumn({name: "entity", label: "Name"}),
search.createColumn({
name: "custcol8",
sort: search.Sort.ASC,
label: "JANコード"
}),
search.createColumn({name: "quantityuom", label: "Quantity in Transaction Units"}),
search.createColumn({name: "statusref", label: "Status"}),
search.createColumn({
name: "quantityonhand",
join: "item",
label: "On Hand"
}),
search.createColumn({
name: "isfulfillable",
join: "item",
label: "Can be Fulfilled"
}),
search.createColumn({name: "department", label: "Department"}),
search.createColumn({name: "otherrefnum", label: "PO/Cheque Number"}),
]
});
Loop and Record Loading:
var matches = [];
salesorderSearchObj.run().each(function(result){
var objRecord = record.load({
type: record.Type.SALES_ORDER,
id: result.id,
isDynamic: true,
});
var push = resultToObject(result);
push.addressid = objRecord.getValue({fieldId:'shipaddresslist'});
log.debug("Result:",push);
matches.push(push);
return true;
});
This works great... Except for the fact that I'm returning around 1000 Sales Orders with the search, meaning that the record.Load() eats through my governance units before I can complete the search and build the entire list of results.
In short, is there a way to return the value of "shipaddresslist" from a Sales Order record directly from the search object? Or perhaps a way to dynamically grab that field without having to load the entire record object?
Any help is greatly appreciated!