我需要事务字段的文本作为通过portlet构建的NetSuite保存的搜索中的变量

我将在我的客户中心环境中添加一个自定义列表portlet,该环境使用一个自定义字段,该字段包含一个表示客户购买的所有商品的内部in的值。该值将用作已保存搜索中的筛选器,该搜索的数据将填充列表portlet。

该字段的文本看起来像"123“、"456”等。

我可以通过我的调试器成功地检索字段文本,但是当我将字段的值作为变量传递给我的过滤器时,它会产生一条错误消息:

Filter expecting numeric value was removed, as non-numeric value ... was provided.

使用NetSuite搜索导出以非动态方式重新创建我要查找的内容,生成以下代码:

var customrecord_vcc_documentsSearchObj = search.create({
   type: "customrecord_vcc_documents",
   filters:
   [
     [["custrecord_vcc_customer_docs","anyof","@CURRENT@"],"AND",["custrecord_vcc_doc_type","noneof","1"]],
      "OR", 
      ["custrecord_vcc_doc_type","anyof","5"],
      "OR", 
      [["custrecord_vcc_doc_type","anyof","2","3","4","6","7"],"AND",["custrecord_vcc_doc_item","anyof","2291","3546","2279","1976"]]
   ],
   columns:
   [
      search.createColumn({
         name: "name",
         sort: search.Sort.ASC,
         label: "Name"
      }),
      search.createColumn({name: "custrecord_vcc_doc_type", label: "Type"}),
      search.createColumn({
         name: "formulatext",
         formula: "'<a href='||{custrecord_vcc_link_to_file}||'>Open</a>'",
         label: "Link"
      })
   ]
});

当我尝试替换:

["custrecord_vcc_doc_item","anyof","2291","3546","2279","1976"]

为了替换固定的In,我使用了以下代码:

var transactionSearchObj = search.create({
   type: "transaction",
   filters:
   [
      ["name","anyof","@CURRENT@"]
   ],
   columns:
   [
      search.createColumn({
         name: "custbody_vcc_item_array_fixed",
         summary: "MAX",
         label: "Item Array Fixed"
      })
   ]
});

var itemarray=[];

transactionSearchObj.run().each(function(result){
    var itemarray1 = result.getValue({
        name: "custbody_vcc_item_array_fixed",
        summary: search.Summary.MAX
    });
    itemarray.push(itemarray1);
    log.debug({
        title: "Items",
        details: itemarray1
    });
    //return true;
});

var itemarraytext = itemarray.toString();

log.debug({
    title: "Item Array String",
    details: itemarraytext
});

log.debug({
    title: "Item Array ",
    details: itemarray
});

并在固定ID的位置输入项目数组文本。每个调试器的itemarraytext的值是:

"2191","2046","1209","1209","1988","2092","295","1214","1988",...

但是错误消息仍然存在,并且未应用筛选器。

这是在NetSuite的客户中心运行的,因此我无法访问客户记录,因为客户中心角色没有访问客户列表的权限。出于同样的原因,我也无法使用{item.internalid}通过保存的搜索直接访问项目内部I:权限。

解决办法是一个动态字段,它设置了一个静态字段,我通过事务搜索对其进行搜索,静态字段文本应该是筛选器的文本。

理想情况下,变量itemarraytext将根据每个客户的购买历史通过并过滤我正在搜索的可用文档。

转载请注明出处:http://www.mingyanggongyi.com/article/20230526/1109255.html