简体   繁体   English

NetSuite:取消SuiteScript中的订单

[英]NetSuite: canceling an order in SuiteScript

In NetSuite, there is a handy button to cancel a salesorder . 在NetSuite中,有一个方便的按钮来取消salesorder We are trying to replicate the behavior of that click in a RESTlet. 我们正在尝试在RESTlet中复制该单击的行为。 We tried the following: 我们尝试了以下方法:

var order = nlapiLoadRecord('salesorder', 802);
order.setFieldText('orderstatus', 'Cancelled');
nlapiSubmitRecord(order);

But we got an error saying that we needed to enter a value for the field Status . 但我们得到一个错误,说我们需要为字段Status输入一个值。 We also tried the following: 我们还尝试了以下方法:

nlapiVoidTransaction('salesorder', 802);

But this gave us an invalid record type error. 但这给了我们一个无效的记录类型错误。 Any thoughts or help would be appreciated. 任何想法或帮助将不胜感激。

I have an open enhancement request for this (#275848). 我有一个开放的增强请求(#275848)。 According to NetSuite support, there is no way to cancel a sales order via SuiteScript or Workflow. 根据NetSuite支持,无法通过SuiteScript或Workflow取消销售订单。

怎么样:

nlapiRequestURL('/app/accounting/transactions/salesordermanager.nl?type=cancel&id=' + nlapiGetRecordId());

您应该使用以下代码和订单状态代码通过SuiteScript进行设置 -

nlapiSubmitField('salesorder',soID,'orderstatus','C',false);

只是一个想法,而不是取消销售订单,你不能只是将closed字段设置为'T'。

Sales Order can be closed by closing each line of item using SuiteScript 2.0 as follows: 可以使用SuiteScript 2.0关闭每行项目来关闭销售订单,如下所示:

orderRecord.setCurrentSublistValue({
                            sublistId: 'item',
                            fieldId: 'isclosed',
                            value: true
                        });

As Netsuite Expert said, you can cancel the sales order transaction by closing each line items in the sales order. 正如Netsuite Expert所说,您可以通过关闭销售订单中的每个行项目来取消销售订单交易。

for(var i = 1; i <= nlapiGetLineItemCount('item'); i++){
    nlapiSetLineItemValue('item', 'isclosed', i, 'T');
}

This is a sample for User event script. 这是用户事件脚本的示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM