我有一个Suitelet脚本,可以提取已保存的Netsuite交易行项目搜索。用户可以检查一行或多行上的已对帐复选框,然后单击提交按钮,脚本将加载每个记录已协调复选框= true并更新记录上的特定行项目,然后提交记录。问题是因为我认为每次迭代= 30个单位,因此我达到了1000的治理限制。有没有办法让我对此进行编码,以便脚本可以加载记录并更新协调复选框= 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++;
}
非常感谢你的帮助 - 我对此非常陌生!
答案 0 :(得分:4)
对于任何类型的批量处理,您几乎肯定需要将处理卸载到预定的脚本。如果你是NS开发的新手,这可能有点先进,但我可能会建议像
创建一个计划脚本,负责执行事务的实际加载和提交。向其中添加脚本参数,以便您可以将数据传递给它。
当在Suitelet上按下提交按钮时,您只需构建一个对象数组,用于描述需要更新的事务和行。
构建数组后,使用nlapiScheduleScript()
调用您的预定脚本,传入数据数据进行处理。
答案 1 :(得分:0)
您可以尝试在套接字上添加一个包含记录内部ID的隐藏列,并将记录ID要处理的行分组。这样,您可以避免多次加载和保存记录,从而消耗使用单位,并且还可以提高套件的性能。