Question

How To find issue Cancel Invoice

  • 5 September 2023
  • 4 replies
  • 115 views

Userlevel 1
Badge

. Invoice To Cancel Invoice Action to show this error How To slove this error ?

public delegate void PersistDelegate();
[PXOverride]
public void Persist(Action del)
{
if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
{
if (Base.Document.Current != null)
{
ARTran objARTran = Base.Transactions.Select().FirstTableItems.ToList().FirstOrDefault();
if (objARTran != null)
{
SOOrder objSOOrder = SOOrder.PK.Find(Base, objARTran.SOOrderType, objARTran.SOOrderNbr);
if (objSOOrder != null)
{
SOOrderExt soOrderExt = objSOOrder.GetExtension<SOOrderExt>();
ARInvoiceExt invoiceExt = Base.Document.Current.GetExtension<ARInvoiceExt>();

invoiceExt.UsrCommentQuote = soOrderExt.UsrCommentQuote;
invoiceExt.UsrIntComment = soOrderExt.UsrIntComment;
invoiceExt.UsrPOComment = soOrderExt.UsrPOComment;
}
}
}
}
del();
}

 


4 replies

Userlevel 4
Badge +2

I would first look at the Trace to see if there is any more error info, or to view the call stack to help determine what line of code is throwing the error.  If you want to post that info, someone can try to help further.

Userlevel 7
Badge +10

Hi @Rajginoya ,

Below Code includes a check to ensure that the Customer ID is not empty before invoking the Persist method:

public delegate void PersistDelegate();
[PXOverride]
public void Persist(Action del)
{
if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
{
if (Base.Document.Current != null)
{
ARTran objARTran = Base.Transactions.Select().FirstTableItems.ToList().FirstOrDefault();
if (objARTran != null)
{
SOOrder objSOOrder = SOOrder.PK.Find(Base, objARTran.SOOrderType, objARTran.SOOrderNbr);
if (objSOOrder != null)
{
SOOrderExt soOrderExt = objSOOrder.GetExtension<SOOrderExt>();
ARInvoiceExt invoiceExt = Base.Document.Current.GetExtension<ARInvoiceExt>();

// Check if Customer ID is not empty before copying data
if (!string.IsNullOrEmpty(objSOOrder.CustomerID))
{
invoiceExt.UsrCommentQuote = soOrderExt.UsrCommentQuote;
invoiceExt.UsrIntComment = soOrderExt.UsrIntComment;
invoiceExt.UsrPOComment = soOrderExt.UsrPOComment;
}
else
{
// Handle the case where Customer ID is empty, e.g., throw an exception or log an error.
// You may need to decide how to handle this situation based on your business logic.
}
}
}
}
}
del();
}

Regards,

Sweta

Userlevel 1
Badge

Hi @Rajginoya ,

Below Code includes a check to ensure that the Customer ID is not empty before invoking the Persist method:

public delegate void PersistDelegate();
[PXOverride]
public void Persist(Action del)
{
if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
{
if (Base.Document.Current != null)
{
ARTran objARTran = Base.Transactions.Select().FirstTableItems.ToList().FirstOrDefault();
if (objARTran != null)
{
SOOrder objSOOrder = SOOrder.PK.Find(Base, objARTran.SOOrderType, objARTran.SOOrderNbr);
if (objSOOrder != null)
{
SOOrderExt soOrderExt = objSOOrder.GetExtension<SOOrderExt>();
ARInvoiceExt invoiceExt = Base.Document.Current.GetExtension<ARInvoiceExt>();

// Check if Customer ID is not empty before copying data
if (!string.IsNullOrEmpty(objSOOrder.CustomerID))
{
invoiceExt.UsrCommentQuote = soOrderExt.UsrCommentQuote;
invoiceExt.UsrIntComment = soOrderExt.UsrIntComment;
invoiceExt.UsrPOComment = soOrderExt.UsrPOComment;
}
else
{
// Handle the case where Customer ID is empty, e.g., throw an exception or log an error.
// You may need to decide how to handle this situation based on your business logic.
}
}
}
}
}
del();
}

Regards,

Sweta
 

Hii,@sweta68
Not Working this Code Changes

Userlevel 4
Badge +2

I would try doing it in a RowPersisting event handler

 


public virtual void _(Events.RowPersisting<ARInvoice> e, PXRowPersisting del)
{
ARInvoice invoice = (ARInvoice)e.Row;
if (invoice != null && e.Cache.GetStatus(invoice) == PXEntryStatus.Inserted)
{
ARTran objARTran = Base.Transactions.Select().TopFirst;
if (objARTran != null)
{
SOOrder objSOOrder = SOOrder.PK.Find(Base, objARTran.SOOrderType, objARTran.SOOrderNbr);
if (objSOOrder != null)
{
SOOrderExt soOrderExt = objSOOrder.GetExtension<SOOrderExt>();
ARInvoiceExt invoiceExt = invoice.GetExtension<ARInvoiceExt>();
//should update current object as its persisting
invoiceExt.UsrCommentQuote = soOrderExt.UsrCommentQuote;
invoiceExt.UsrIntComment = soOrderExt.UsrIntComment;
invoiceExt.UsrPOComment = soOrderExt.UsrPOComment;
}
}
}

del?.Invoke(e.Cache, e.Args);
}

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved