NetSuite。将一个销售代表和一个应收账款账户附加到客户记录上。

问题描述 投票:0回答:1

我正在尝试更新客户,我试图给新创建的客户附加一个销售代表和一个应收账款账户。

当我使用以下代码时,我遇到了以下错误。ReferenceError: "RecordRef" is not defined: "RecordRef "没有定义。

/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */
define(['N/currentRecord'],
    function(currentRecord) {
  function beforeSubmit(context) {
    var curRecord = context.newRecord;
    curRecord.salesrep = new RecordRef(){
      InternalId: "-5"
    };
    curRecord.receivablesAccount = new RecordRef(){
      ??? how to retrieve the id ?
    };
    try {
      log.debug('record created successfully');
    } catch (e) {
      log.error(e.name);
    }
  }
        return {
            beforeLoad: beforeLoad,
            beforeSubmit: beforeSubmit,
            afterSubmit: afterSubmit
        };
    });
netsuite suitescript
1个回答
1
投票

RecordRef() 如果你想通过C#或PHP的SOAP网络服务连接到NetSuite,你会使用SuiteScript。 在SuiteScript中,你可以使用 .setValue() 来设置这些值。

/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */
define([],
  function () {
    function beforeSubmit(context) {
      var curRecord = context.newRecord;
      curRecord.setValue({ fieldId: 'salesrep', value: -5 });
      curRecord.setValue({ fieldId: 'receivablesaccount', value: 7 });
    }

    return {
      beforeSubmit: beforeSubmit,
    };
  }
);

要找到你的会计科目表的内部ID,请导航到 Home -> Set Preferences,检查 显示内部IDS 框,然后单击 保存. 然后导航到 Setup -> Accounting -> Chart of Accounts. 您应该能够找到您希望使用的应收账款账户的内部ID。

此外, N/currentRecord 模块只能在客户端脚本和模块中使用,不应该在用户事件脚本中使用。

© www.soinside.com 2019 - 2024. All rights reserved.