Wal*_*lcz 0 javascript netsuite suitescript
我正在尝试使用 SuiteScript 2.0 编写 Restlet,为我的公司创建新的销售订单。我找到了如何创建一个 record.Type.Sales_Order 并暂时输入最小值,但我不知道如何为销售订单创建一个项目并将其包含在 SO 中,以便我可以创建销售订单。
这是我到目前为止所得到的(在 GET 中):
var salesOrder = record.create({
type: record.Type.SALES_ORDER,
isDynamic: true,
defaultValues: {
entity: param.customer_id
}
});
salesOrder.setValue('trandate', new Date()),
salesOrder.setText('orderstatus','Pending Fulfillment');
salesOrder.setValue('memo','Sales Order Generated from ' + param.customer_name);
salesOrder.save();
Run Code Online (Sandbox Code Playgroud)
我是否要创建一个项目类型的新记录,然后在保存之前将其添加到销售订单中?我浏览了 netsuite.com 的帮助部分,但找不到任何有关为销售订单创建项目的信息。
感谢您提供任何答案或可查找的地方:)
在将物料记录添加到销售订单之前,该物料记录必须存在。因此,如果您需要添加尚未创建的项目,则需要先创建项目记录。但是,如果您询问如何将现有项目添加到销售订单的项目子列表中,您可以执行以下操作:
var salesOrder = record.create({
type: record.Type.SALES_ORDER,
isDynamic: true,
defaultValues: {
entity: param.customer_id
}
});
salesOrder.selectNewLine({ //add a line to a sublist
sublistId: 'item' //specify which sublist
});
salesOrder.setCurrentSublistValue({ //set item field
sublistId: 'item',
fieldId: 'item',
value: {{itemid}} //replace with item internal id
});
salesOrder.setCurrentSublistValue({
sublistId: 'item',
fieldId: 'quantity',
value: {{quantity}} //replace with quantity
});
//repeat above pattern to set the rest of the line fields
salesOrder.commitLine({ //writes the line entry into the loaded record
sublistId: 'item'
});
salesOrder.save({ //writes record back to database
ignoreMandatoryFields: true //set for testing in case you want to create a record without validating which can give errors
});
Run Code Online (Sandbox Code Playgroud)
华泰