首页 > 解决方案 > 在 Suitscript 2.0 的 Suitelet 中使用 N/record

问题描述

我正在尝试使用 Suitelet 中的 n/record 模块加载记录,但出现以下错误:

org.mozilla.javascript.EcmaError: TypeError: Cannot read property "SALES_ORDER" from undefined

 * @NApiVersion 2.x
 * @NScriptType Suitelet
 */

define(['./form', 'N/record'],
    function(form, record) {

        function onRequest(context) {

            if(context.request.method === 'GET'){
                var ratingForm = form.build(context);


                var customRec = record.load({
                    type: record.TYPE.SALES_ORDER,
                    id: 18
                });

这在一个表单中,我想加载一条记录,并使用现有的 SALES_ORDER 记录预填充我可以使用的任何字段。

也许我需要以不同的方式解决这个问题?

标签: netsuitesuitescript2.0

解决方案


更新您record.load的如下

var customRec = record.load({
  type: record.Type.SALES_ORDER,
  id: 18
});

您可以查看所有受支持的记录类型列表。


推荐阅读