简体   繁体   English

如何从交易保存搜索/Suitescript 搜索中获取销售订单“shipaddresslist”值?

[英]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.在 Netsuite 中,销售订单记录类型包含一个名为“ shipaddresslist ”的字段,其中包含与所选客户地址关联的客户地址内部 ID。

Unfortunately, there is no search column for Sales Orders that will get the value of " shipaddresslist ," so I had to find a workaround.不幸的是,没有可获取“ shipaddresslist ”值的 Sales Orders 搜索列,因此我不得不寻找解决方法。

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使用 SuiteScript,我已经能够通过循环搜索结果、将销售订单 ID 传递给 record.Load() function 并在加载的记录上调用 record.getValue() 来获取该字段的值,如下所示如下所示

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.这很好用......除了我通过搜索返回大约 1000 个销售订单这一事实,这意味着 record.Load() 在我完成搜索并构建整个结果列表之前吃掉了我的治理单元。

In short, is there a way to return the value of " shipaddresslist " from a Sales Order record directly from the search object?简而言之,有没有办法直接从搜索 object 中返回销售订单记录中“ shipaddresslist ”的值? Or perhaps a way to dynamically grab that field without having to load the entire record object?或者也许是一种无需加载整个记录 object 即可动态获取该字段的方法?

Any help is greatly appreciated!任何帮助是极大的赞赏!

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.出于我的目的,我只使用 SuiteScript,因为我认为您无法在 Netsuite 本身中获得该字段,但事实证明我错了。 Here's how to get the field in Netsuite:以下是在 Netsuite 中获取该字段的方法:

Solution解决方案

1: Navigate to Lists> Search> Saved Searches> New 1:导航到列表>搜索>保存的搜索>新建

2: Select Transaction 2:Select 交易

3: Under the Criteria tab, Standard subtab, add the following filters: 3:在 Criteria 选项卡的 Standard 子选项卡下,添加以下过滤器:

---Select the Type: Select type of transaction you want to pull up ---选择Type: Select 你要拉起的交易类型

---Shipping address: Is not empty ---送货地址:不为空

---Main Line is True ---主线是真的

---Formula (Text): DECODE({shipaddress}, {customer.address},'1','0') Starts with 1 ---公式(文本):DECODE({shipaddress}, {customer.address},'1','0') 以 1 开头

4: Under the Results tab add the following columns: 4:在“结果”选项卡下添加以下列:

---Shipping Address - -收件地址

---Customer/project fields is Address Internal id ---客户/项目字段是地址内部ID

5: Name the search and hit Save & Run. 5:为搜索命名并点击保存并运行。

The only required criteria is the Formula, but this solution is copy and pasted from SuiteAnswers.唯一需要的标准是公式,但此解决方案是从 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.感谢 r/Netsuite subreddit 上的 u/seekcant 找到并发布了这个解决方案。

If you are looking for Internal ID of the customer address, you can add this to the search columns如果您正在寻找客户地址的内部 ID,您可以将其添加到搜索列中

search.createColumn({
         name: "internalid",
         join: "shippingAddress",
         label: "Internal ID"
      })

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM