我有一个 Suitelet 脚本,可以提取已保存的 Netsuite 交易行项目搜索。用户可以选中一行或多行上的已协调复选框,然后单击提交按钮,脚本将加载已协调复选框 = true 的每条记录并更新记录上的特定行项目,然后提交记录。问题是我达到了 Suitescript 1000 的治理限制,因为我认为每次迭代 = 30 个单位。有没有办法让我对此进行编码,以便脚本可以加载记录并更新已协调复选框 = true 的所有行项目,然后提交记录?在大多数情况下,我只打开 4 - 5 条记录,但更新每条记录上的许多行。这是我当前正在使用的代码。
for(var i=1; i< count+1; i++)
{
//get the value of the reconcile checkbox
var reconcileTransaction = request.getLineItemValue('custpage_transaction_list', 'reconcile', i);
// If it's checked, reconcile the transaction
if(reconcileTransaction == 'T')
{
// Get the transaction internal ID
var internalId = request.getLineItemValue('custpage_transaction_list', 'internalid', i);
// Get the transaction type
var recordType = request.getLineItemValue('custpage_transaction_list', 'recordtype', i);
var recordLine = request.getLineItemValue('custpage_transaction_list', 'linesequencenumber', i);
// var totalAmount = totalAmount + request.getLineItemValue('custpage_transaction_list', 'amount', i);
try
{
var recTransaction = nlapiLoadRecord(recordType, internalId);
recTransaction.setLineItemValue('expense', 'custcol2',recordLine, 'T');
recTransaction.setLineItemValue('expense', 'custcol_date_reconciled',recordLine, date1);
nlapiSubmitRecord(recTransaction);
//recTransaction.setLineItemValue('expense', 'custcol4', recordLine, periodReconcile);
num++;
}
非常感谢您的帮助 - 我对此很陌生!
最佳答案
对于像这样的任何类型的批量处理,您几乎肯定需要将处理卸载到计划的脚本。如果您是 NS 开发新手,这可能有点高级,但我可能会建议类似
创建一个计划脚本,负责执行实际的事务加载和提交。向其中添加脚本参数,以便您可以向其中传递数据。
当按下 Suitelet 上的提交按钮时,您只需构建一个对象数组来描述哪些交易和行需要更新。
构建数组后,使用
nlapiScheduleScript()
调用您的计划脚本,传入您的数据数组进行处理。
关于javascript - Netsuite Suitelet : Iterate through a list of transaction line items Load and Submit record without reaching Governance Limits,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29435063/