The AR Division Number is required

SOLVED

Hello,

I am creating AR_Invoice via BOI. We have Account Receivable Division check box unchecked. I assume ARDivisionNo$ is optional. Here is my code

//Set the A/P Invoice Header record


retVal = oARInvoice.nSetValue("InvoiceDate$", _invoiceDate);

retVal = oARInvoice.nSetValue("InvoiceType$", "IN");

retVal = oARInvoice.nSetKeyValue("InvoiceNo$",  _invoiceNo);

retVal = oARInvoice.nSetValue("ARDivisionNo$", "00");
if (retVal == 0)
throw new Exception("Sage Error - Failed to set ARDivisionNo: " + oARInvoice.sLastErrorMsg);//< -- no error

retVal = oARInvoice.nSetKey();
retVal = oARInvoice.nSetValueNoValidate("CustomerNo$", _customerNo);

.

.

.

 (int)oARInvoice.nWRITE(); //<-- I am getting "The AR Division Number is required" error

Additional note, if I don't set "ARDivisionNo$", I am getting error "ARDivisionNo$ is required".

Any idea, how to fix this.

Thanks in advance.