Skip to content
Advertisement

How to get Sales Order ‘shipaddresslist’ value from Transaction Saved Search/Suitescript Search?

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!

Advertisement

Answer

SOLVED (KINDA)

Hey all, I asked around and got a semi-solution so in case anyone else comes across this problem, here is a solution.

For my purposes, I was only using SuiteScript because I didn’t think you could get the field in Netsuite itself, but I was proved wrong. Here’s how to get the field in Netsuite:

Solution

1: Navigate to Lists> Search> Saved Searches> New

2: Select Transaction

3: Under the Criteria tab, Standard subtab, add the following filters:

—Select the Type: Select type of transaction you want to pull up

—Shipping address: Is not empty

—Main Line is True

—Formula (Text): DECODE({shipaddress}, {customer.address},’1′,’0′) Starts with 1

4: Under the Results tab add the following columns:

—Shipping Address

—Customer/project fields is Address Internal id

5: Name the search and hit Save & Run.

The only required criteria is the Formula, but this solution is copy and pasted from SuiteAnswers. I recommend just using the Formula and adding in criteria needed as you see fit.

Credit goes to u/seekcant on the r/Netsuite subreddit for finding and posting this solution.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement