简体   繁体   中英

NetSuite: canceling an order in SuiteScript

In NetSuite, there is a handy button to cancel a salesorder . We are trying to replicate the behavior of that click in a 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 . 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). According to NetSuite support, there is no way to cancel a sales order via SuiteScript or 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:

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.

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

This is a sample for User event script.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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