在提交供应商账单并通过预定脚本进行处理时,我们遇到了一个奇怪的问题。
每次脚本尝试调用 nlapisubmitrecord(vendorbil,true, true) 时,都会引发异常:USER_ERROR:请输入帐户/金额的值。
有趣的是,如果在 API 调用之前调用 account 和 amount 的值并且两个值都是正确的。另外,由于我们指定了 IgnoreMandatoryFields = true,不应该忽略这些字段(即使它们是空的?)
所以我们的疑问是:netsuite API 调用发生了变化和中断?会发生吗?
请问有什么帮助吗?
谢谢..
[更新 1]
多谢你们 ....
正在破坏的代码如下:
i = parseInt(nlapiGetLineItemCount('expense'), 10);
while (i > 0) {
lineSubsidiaryId = isNumber(nlapiGetLineItemValue('expense', 'custcol_project_sub_bill', i)) ? parseInt(nlapiGetLineItemValue('expense', 'custcol_project_sub_bill', i), 10) : origSubsidiary;
taxCodeId = isNumber(nlapiGetLineItemValue('expense', 'taxcode', i)) ? parseInt(nlapiGetLineItemValue('expense', 'taxcode', i), 10) : -1;
hasAmortizationSchedule = isNumber(nlapiGetLineItemValue('expense', 'custcol_custom_amortization_schedule', i)) && isNotBlank(nlapiGetLineItemValue('expense', 'custcol_amort_start', i)) && isNotBlank(nlapiGetLineItemValue('expense', 'custcol_amort_end', i));
if (lineSubsidiaryId !== origSubsidiary) {
if (VENDORBILL_DEBUG) {
nlapiLogExecution('DEBUG', 'DH_VendorBill_BeforeSubmit', 'Found a line assigned to a different subsidiary');
}
nlapiSetFieldValue('custbody_dh_vendorbill_status', INVOICE_PROCESS_STATUS.Pending);
} else {
// Copy the custom 'Allocate to Project' field into the Standard 'customer' field
// check for blankeness ... don't bother copying
if (isNumber(nlapiGetLineItemValue('expense', 'custcol_allocate_to_project', i))) {
nlapiSetLineItemValue('expense', 'customer', i, nlapiGetLineItemValue('expense', 'custcol_allocate_to_project', i));
}
// Copy the custom 'Bill End Customer' field into the Standard 'isbillable' field
nlapiSetLineItemValue('expense', 'isbillable', i, nlapiGetLineItemValue('expense', 'custcol_ec_bill_end_customer', i));
// Account for Amortization Schedule (See Issue #2)
if (hasAmortizationSchedule) {
nlapiSetLineItemValue('expense', 'amortizationsched', i, nlapiLookupField('customrecord_cust_amort_templates', nlapiGetLineItemValue('expense', 'custcol_custom_amortization_schedule', i), 'custrecord_amort_temp_internal_id'));
nlapiSetLineItemValue('expense', 'amortizstartdate', i, nlapiGetLineItemValue('expense', 'custcol_amort_start', i));
nlapiSetLineItemValue('expense', 'amortizationenddate', i, nlapiGetLineItemValue('expense', 'custcol_amort_end', i));
}
if (taxCodeId !== -1) {
nlapiSetLineItemValue('expense', 'taxcode', i, taxCodeId);
}
}
i = i - 1;
}