on 08-25-2023 6:47 AM
Hello all,
I am getting an error when trying to cancel an invoice through SDK.
The error is: System.NullReferenceException
The code is:
#region Cancel invoice
SAPbobsCOM.Documents sboCancel = (SAPbobsCOM.Documents)oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oInvoices);
sboCancel.GetByKey(docEntry);
SAPbobsCOM.Documents cancelDoc = sboCancel.CreateCancellationDocument();
int cancel = cancelDoc.Add(); <-- Error thrown here
if (cancel != 0)
{
ErrorLog.LoggerExceptionInfo(new Exception("Error " + oCompany.GetLastErrorDescription().ToString() + Environment.NewLine));
return;
}
else
{
ErrorLog.LoggerExceptionInfo(new Exception("Invoice cancelled for DocNum: " + item.DocNum));
}
#endregion
Any help appreciated.
Hi kinyanjuikamau,
Is it trying to Cancel the correct document?
Can you try the following?
if (sboCancel.GetByKey(docEntry))
{
// Do the operation.
}
Hope it helps!
Kind regards,
ANKIT CHAUHAN
SAP Business One Support
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
9 | |
6 | |
6 | |
4 | |
3 | |
3 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.