Reputation: 115
We are facing a strange issue while submitting vendor bills and processing it through a scheduled script.
Everytime the script tries to call nlapisubmitrecord(vendorbill,true, true), it throws an exception : USER_ERROR : Please enter values for Account/ amount.
Funny part is, if values of account and amount are called just before the API call and both the values are correct. Also, since we have specified IgnoreMandatoryFields = true, shouldnt it be ignore these fields ( even if they are empty ?)
So our doubt is: netsuite API call is changed and breaking ? Can it happen ?
Any help please ?
Thanks..
[Update 1]
Thanks guys ....
The code which is breaking is as below:
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;
}
Upvotes: 0
Views: 1341
Reputation: 115
Thank you all for your help .... We found a solution and root cause.
As a part of recent development work, we had introduced a filter on one of the fields of the line item. That filter was not returning values and somehow adding null lines. After we removed that filter, now the script started working perfectly fine.
Weird issues.. But glad we cud fix it ..
Upvotes: 0
Reputation: 924
Check that you are not adding more line items than needed, and that you are committing all lines.
Upvotes: 1