0

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;
}
peak
  • 105,803
  • 17
  • 152
  • 177
FreeMarker12
  • 115
  • 1
  • 10
  • Can you provide a snippet of the code you are using? – Rusty Shackles Feb 11 '16 at 00:23
  • 1
    BTW! it is not `nlapisubmitrecord` it is `nlapiSubmitRecord`. Please add some code snipet – Rockstar Feb 11 '16 at 04:29
  • Thanks guys .. please check it – FreeMarker12 Feb 12 '16 at 03:31
  • I'm not sure exactly the issue. But you're question is about nlapiSubmitRecord....yet you aren't "loading" any record in your code with nlapiLoadRecord. You seem to be setting all your line item fields using nlapiSetLineItemValue and not record.setLineItemValue(...). In terms of troubleshooting, I'd recommend commenting out your nlapiSetLineItemValue() fields and test if it works. Then add them in one by one to isolate your issue. – Lez Yeoh Feb 12 '16 at 12:10

2 Answers2

1

Check that you are not adding more line items than needed, and that you are committing all lines.

felipechang
  • 916
  • 6
  • 14
0

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 ..

FreeMarker12
  • 115
  • 1
  • 10