简体   繁体   English

如何在 Netsuite Suitescript 2.0 中按 CompanyId 搜索案例?

[英]How to search cases by CompanyId in Netsuite Suitescript 2.0?

I can able to search the case by company name我可以通过公司名称搜索案例

var mySearch = search.create({
      type: search.Type.SUPPORT_CASE,
       columns: [{
          name: 'title'
      }, {
          name: 'company'
      }],
      filters: [{
          name: 'company',
          operator: 'is',
          values: 'Test'
      }]
  });
  return mySearch.run({
    ld: mySearch.id
  }).getRange({
      start: 0,
      end: 1000
  });

But I am not able to search case by company id.但我无法通过公司 ID 搜索案例。 companyId is 115公司 ID 为 115

Below are not working下面不工作

i)一世)

filters: [{
          name: 'company',
          operator: 'is',
          values: 115
      }]

ii) ii)

filters: [{
          name: 'companyid',
          operator: 'is',
          values: 115
      }]

According to the Case schema company is a Text filter, meaning you would have to provide it with the precise Name of the company, not the internal ID.根据案例模式, company是一个文本过滤器,这意味着您必须为其提供公司的准确名称,而不是内部 ID。

Instead you may want to use the customer.internalid joined filter to provide the internal ID.相反,您可能希望使用customer.internalid加入过滤器来提供内部 ID。 Also, Internal ID fields are nearly always Select fields, meaning they do not accept the is operator, but instead require the anyof or noneof operator.此外,内部 ID 字段几乎总是 Select 字段,这意味着它们不接受is运算符,而是需要anyofnoneof运算符。

You can find the valid operators by field type on the Help page titled Search Operators您可以在标题为“ Search Operators ”的“帮助”页面上按字段类型查找有效运算Search Operators

First, you can try this :首先,你可以试试这个:

var supportcaseSearchObj = search.create({
   type: "supportcase",
   filters:
   [
      ["company.internalid","anyof","100"]
   ],
   columns:
   [
      search.createColumn({
         name: "casenumber",
         sort: search.Sort.ASC
      }),
      "title",
      "company",
      "contact",
      "stage",
      "status",
      "profile",
      "startdate",
      "createddate",
      "category",
      "assigned",
      "priority"
   ]
});

Second : how did I get this ?第二:我是怎么得到这个的? The answer is hint that will make your life easier :答案是暗示会让你的生活更轻松:

  1. Install the "NetSuite Saved Search Code Export" chrome plugin.安装“NetSuite Saved Search Code Export”chrome 插件。
  2. In Netsuite UI, create your saved search (it is always easier that doing it in code).在 Netsuite UI 中,创建您保存的搜索(在代码中执行总是更容易)。
  3. After saving the search, open it again for edition.保存搜索后,再次打开进行编辑。
  4. At the top right corner (near list, search menu in the netsuite page), you will see a link "Export as script" : click on it and you will get your code ;)在右上角(靠近列表,netsuite 页面中的搜索菜单),您将看到一个链接“导出为脚本”:单击它,您将获得您的代码;)

If you can not install the chrome plugin :如果您无法安装 chrome 插件:

  1. In Netsuite UI, create your saved search (it is always easier that doing it in code).在 Netsuite UI 中,创建您保存的搜索(在代码中执行总是更容易)。
  2. In your code, load your saved search在您的代码中,加载您保存的搜索
  3. Add a log.debug to show the [loadedesearchVar].filters添加 log.debug 以显示[loadedesearchVar].filters
  4. You can then copy what you will see in the log to use it as your search filters.然后,您可以复制您将在日志中看到的内容,将其用作搜索过滤器。

Good luck!祝你好运!

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

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