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

我正在我的客户中心环境中添加一个自定义列表 portlet,该 portlet 使用一个自定义字段,该字段包含一个表示客户购买的所有项目的内部 ID 的值。此值将用作已保存搜索中的过滤器,其数据将填充列表 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"]


慕运维8079593
浏览 224回答 2
2回答

HUH函数

如果我理解正确,您正在构建一个逗号分隔项的字符串数组:[&nbsp; &nbsp; '"2191","2046","1209"',&nbsp; &nbsp; '"1209","1988","2092"',&nbsp; &nbsp; '"295","1214","1988"']然后调用 toString 方法来创建:'"2191","2046","1209","1209","1988","2092","295","1214","1988"'并将该字符串传递给您的搜索过滤器:["custrecord_vcc_doc_item","anyof",'"2191","2046","1209","1209","1988","2092","295","1214","1988"']并且过滤器无法识别'"2191","2046","1209","1209","1988","2092","295","1214","1988"'为数字。相反,您需要替换双引号并在逗号处拆分 itemarraytext 变量:["custrecord_vcc_doc_item","anyof",itemarraytext.replace(/"/g,'').split(',')];这应该相当于:["custrecord_vcc_doc_item","anyof",["2191","2046","1209","1209","1988","2092","295","1214","1988"]]
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript