【问题标题】:Creating dynamic customer group using suite script使用 suitescript 创建动态消费者组
【发布时间】:2015-10-24 07:57:55
【问题描述】:

我正在尝试使用 Net 套件中的套件脚本创建动态客户组,我正在尝试以下代码但总是得到
system INVALID_KEY_OR_REF
Invalid savedsearch reference key 21.

我已经检查了它是有效的保存搜索,请帮助我做错了什么。

function createDynamicGroup(savedSearchId, groupName) {
var saveSearchObj = nlapiLoadSearch('customer', savedSearchId);
var initValues = new Array();
initValues.grouptype = 'Customer';
initValues.dynamic = 'T';
var goupRecObj = nlapiCreateRecord('entitygroup', initValues);
goupRecObj.setFieldValue('groupname', groupName);
goupRecObj.setFieldValue('savedsearch',saveSearchObj.getId());
nlapiSubmitRecord(goupRecObj);
}

【问题讨论】:

  • 保存的搜索是公共搜索吗?您是否检查过在用户界面中创建动态组时是否可以选择相同的搜索?
  • 是的,保存搜索是公共搜索,我可以使用 UI 使用该搜索创建组

标签: netsuite suitescript


【解决方案1】:

您需要 group type = 'CustJob' 以及使用公共搜索 ID:

function createDynamicGroup(savedSearchId, groupName) {
    var saveSearchObj = nlapiLoadSearch('customer', savedSearchId);
    var initValues = {
        grouptype: 'CustJob', // <-- use this
        dynamic: 'T'
    };
    var goupRecObj = nlapiCreateRecord('entitygroup', initValues);
    goupRecObj.setFieldValue('groupname', groupName);
    goupRecObj.setFieldValue('savedsearch', savedSearchId);
    return nlapiSubmitRecord(goupRecObj);
}

【讨论】:

  • 您的解决方案有效,我们需要将组类型传递为CustJob,但是您是如何找到信息的,一般应该是客户。
  • 奇怪的是,几天前我自己也发现了一个类似的问题。我最终在控制台中加载了一个现有组并检查了它的 grouptype 字段。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-02-26
  • 1970-01-01
  • 1970-01-01
  • 2020-02-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多