【发布时间】:2018-01-08 23:24:39
【问题描述】:
编辑:我已经编辑了实际数字并用伪誓言替换了它们,因为我被告知共享性能数据违反了 Netsuite 的 TOS。
我正在使用 restlets 将我们的会计系统与 NetSuite 集成,总体而言,除了性能方面的明显例外,它运行良好。从性能的角度来看,我已经发现 nlapiLoadRecord 是撒旦自己的孩子,所以我尽可能避免使用它来支持搜索 api,现在我的读取 restlets 非常活泼。然而,每当我让一个休息者写任何东西时,它就像一只被困在冷焦油中的乌龟一样慢。我通常在 SLOW 和 REALLY DAMN SLOW 秒之间分析 nlapiSubmitRecord 本身。这对我来说似乎很疯狂。如果编写性能总是这么差,没有人会使用 NetSuite。我将在下面包含几个代码示例。任何有关加快 NetSuite restlet 写入性能的提示都将不胜感激。
在第一个中 receivedInvoice 是传入数据,findCurrencyCode 和 findCustomerByCustomerNumber 是执行这些操作的良好函数。我刚刚在一个几乎令人难以置信的 HOLY MONKEYS 太慢 秒内完成了一张简单的发票,其中包含一个行项目,几乎所有时间都在等待 nlapiSubmitRecord 完成。
var createdInvoice = nlapiCreateRecord('invoice');
createdInvoice.setFieldValue('customform', Number(receivedInvoice.transactionType));
createdInvoice.setFieldValue('memo', receivedInvoice.message);
createdInvoice.setFieldValue('duedate', receivedInvoice.dateDue);
createdInvoice.setFieldValue('currency', findCurrencyCode(receivedInvoice.currencyUnit));
createdInvoice.setFieldValue('location', Number(receivedInvoice.location));
createdInvoice.setFieldValue('postingperiod', findPostingPeriod(receivedInvoice.datePosted));
var customer = findCustomerByCustomerNumber(receivedInvoice.customerNumber);
createdInvoice.setFieldValue('entity', customer.customerId );
createdInvoice.setFieldValue('custbody_end_user', customer.customerId );
createdInvoice.setFieldValue('department', customer.departmentId);
var itemCount = receivedInvoice.items.length;
for(var i = 0; i < itemCount; i++)
{
createdInvoice.selectNewLineItem('item');
createdInvoice.setCurrentLineItemValue('item', 'item',receivedInvoice.items[i].item);
createdInvoice.setCurrentLineItemValue('item', 'quantity', receivedInvoice.items[i].quantity);
createdInvoice.setCurrentLineItemValue('item', 'rate',receivedInvoice.items[i].price);
createdInvoice.setCurrentLineItemValue('item', 'custcol_list_rate',receivedInvoice.items[i].price);
createdInvoice.setCurrentLineItemValue('item', 'amount',receivedInvoice.items[i].totalAmount);
createdInvoice.setCurrentLineItemValue('item', 'description',receivedInvoice.items[i].description);
createdInvoice.commitLineItem('item');
}
var recordNumber = nlapiSubmitRecord(createdInvoice,false,true);
在这一个中,我认为我通过在动态模式下打开记录来犯下性能异端,但我不确定如何获得可能的订单项。只需在 SLOW 秒左右以动态模式打开新记录。同样,提交是消耗时间最多的地方(通常在 OH DEAR SWEET MOTHER OF HORRIBLE 秒左右),尽管由于我弄乱了订单项,这一次消耗了相当多的时间,大概是因为我已经以动态模式打开了记录。
var customerPayment = nlapiCreateRecord('customerpayment',{recordmode: 'dynamic'});
customerPayment.setFieldValue('customer', parseInt(customerId));
customerPayment.setFieldValue('payment', paymentAmount);
customerPayment.setFieldValue('paymentmethod', paymentMethod);
customerPayment.setFieldValue('checknum', transactionId);
customerPayment.setFieldValue('currency', currency);
customerPayment.setFieldValue('account', account);
var applyCount = customerPayment.getLineItemCount('apply');
if(applyCount>0)
{
for(var i=1;i<=applyCount;i++)
{
var thisInvoice = customerPayment.getLineItemValue('apply','refnum',i);
if(thisInvoice == invoiceToPay)
{
customerPayment.selectLineItem('apply', i);
customerPayment.setCurrentLineItemValue('apply','apply','T');
customerPayment.setCurrentLineItemValue('apply', 'amount',paymentAmount);
customerPayment.commitLineItem('apply');
}
}
}
nlapiSubmitRecord(customerPayment,false,true);
【问题讨论】:
-
谢谢你的伪誓——他们让我哈哈大笑。另外:分享性能违反了他们的服务条款......?这是 NetSuite 默许他们的表现惨不忍睹?
-
不幸的是,公司这样做似乎并不少见:stackoverflow.com/questions/12115397/…
-
Powercow,你曾经解决过你的性能问题吗?您是在 Netsuite 的沙盒环境还是生产环境中进行了测试?在生产环境中性能是否更好?
-
问题依然存在。我使用了各种技巧来更快地获得写入性能,但以任何标准衡量,性能仍然很糟糕且无法接受。尽管生产环境比沙盒环境执行得更好,但如果它在生产中不是问题,我就不会在这里。在这一点上,在与 NetSuite 的支持人员进行了广泛的交谈后,我相信 NetSuite 的写入性能非常糟糕,您只能期望要么异步写入并稍后处理错误,要么接受糟糕的性能。认为这是一种强烈的反背书。
标签: javascript performance netsuite suitescript