SuiteScript 中的 ID 字段抛出 INVALID_FLD_VALUE
Id field throwing INVALID_FLD_VALUE in SuiteScript
在 Suitescript 中创建新的销售订单并为项目设置子列表值时,抛出 INVALID_FLD_VALUE 错误。
我传递的值是项目的内部 ID,我尝试使用多个项目的内部 ID,无论是否带引号,都收到相同的错误。代码如下
/**
* @NApiVersion 2.0
* @NScriptType Restlet
* @NModuleScope SameAccount
*/
define(['N/record'], function (r) {
function get(context) {
try {
// Create new record type of SALES_ORDER
var salesOrder = r.create({
type: r.Type.SALES_ORDER,
isDynamic: false,
defaultValues: null
})
// CREATE AN ITEM AND SET VALUES
salesOrder.insertLine({
sublistId: 'item',
line: 0
});
// Item Intetrnal ID
salesOrder.setSublistValue({
sublistId: 'item',
fieldId: 'item',
line: 0,
value: '15'
});
// Quantity
salesOrder.setSublistValue({
sublistId: 'item',
fieldId: 'quantity',
line: 0,
value: 4
});
salesOrder.save();
return JSON.stringify('Sales Order Created');
}
catch (err) {
log.audit({
title:'Error',
details: err
})
return JSON.stringify(err);
}
}
return {
get: get
}
})
我几乎逐行看到使用此代码编写的教程,这让我想知道这是否与 NetSuite 中需要转换的功能或设置有关 on/off。非常感谢任何反馈。
错误是因为我在继续添加子列表项之前没有设置 "entity" 字段。所以错误实际上不是项目 id 值的结果。
有效代码:
var salesOrder = r.create({
type: r.Type.SALES_ORDER,
isDynamic: true,
defaultValues: Date.now().toString
}).setValue({
fieldId: "entity",
value: customer
})
salesOrder.selectNewLine({ sublistId: "item" });
salesOrder.setCurrentSublistValue({
sublistId: "item",
fieldId: "item",
value: itemId
});
salesOrder.setCurrentSublistValue({
sublistId: "item",
fieldId: "quantity",
value: 5
});
salesOrder.commitLine({ sublistId: "item" });
salesOrder.save({
enableSourcing: true,
ignoreMandatoryFields: true
})
在 Suitescript 中创建新的销售订单并为项目设置子列表值时,抛出 INVALID_FLD_VALUE 错误。
我传递的值是项目的内部 ID,我尝试使用多个项目的内部 ID,无论是否带引号,都收到相同的错误。代码如下
/**
* @NApiVersion 2.0
* @NScriptType Restlet
* @NModuleScope SameAccount
*/
define(['N/record'], function (r) {
function get(context) {
try {
// Create new record type of SALES_ORDER
var salesOrder = r.create({
type: r.Type.SALES_ORDER,
isDynamic: false,
defaultValues: null
})
// CREATE AN ITEM AND SET VALUES
salesOrder.insertLine({
sublistId: 'item',
line: 0
});
// Item Intetrnal ID
salesOrder.setSublistValue({
sublistId: 'item',
fieldId: 'item',
line: 0,
value: '15'
});
// Quantity
salesOrder.setSublistValue({
sublistId: 'item',
fieldId: 'quantity',
line: 0,
value: 4
});
salesOrder.save();
return JSON.stringify('Sales Order Created');
}
catch (err) {
log.audit({
title:'Error',
details: err
})
return JSON.stringify(err);
}
}
return {
get: get
}
})
我几乎逐行看到使用此代码编写的教程,这让我想知道这是否与 NetSuite 中需要转换的功能或设置有关 on/off。非常感谢任何反馈。
错误是因为我在继续添加子列表项之前没有设置 "entity" 字段。所以错误实际上不是项目 id 值的结果。
有效代码:
var salesOrder = r.create({
type: r.Type.SALES_ORDER,
isDynamic: true,
defaultValues: Date.now().toString
}).setValue({
fieldId: "entity",
value: customer
})
salesOrder.selectNewLine({ sublistId: "item" });
salesOrder.setCurrentSublistValue({
sublistId: "item",
fieldId: "item",
value: itemId
});
salesOrder.setCurrentSublistValue({
sublistId: "item",
fieldId: "quantity",
value: 5
});
salesOrder.commitLine({ sublistId: "item" });
salesOrder.save({
enableSourcing: true,
ignoreMandatoryFields: true
})