Skip to main content
Answer

SOShipmentEntry CreateInvoice override "Base.Document.Current" property null when ran from Process Shipments

  • September 21, 2022
  • 3 replies
  • 307 views

Forum|alt.badge.img+1

I have an override on the SOShipmentEntry CreateInvoice action that works fine when the Prepare Invoice button is pressed on the Shipments screen, but not when it is ran through the Process Shipments screen.  The screenshot below is a simplified version of the override.  The Base.Document.Current.ShipmentNbr field is null and also Base.Transactions.Select() returns no records.  

What am I missing?  I need a reference to the shipment nbr so I can reference back to the order to update some custom fields on the invoice that’s generated.

 

Thanks

Scott

Best answer by Leonardo Justiniano

@scottstanaland12 

 

Yes, adapter contains all selected SOShipment records, or 1 record in case of the Shipment screen.

About your question, you can create an RowInserted event in a SOInvoiceEntry extension looking at SOOrderShipment table (InvoiceNbr & ShipmentNbr):

namespace PX.Objects.SO
{
public class SOInvoiceEntry_Extension : PXGraphExtension<SOInvoiceEntry>
{
#region Event Handlers
protected void _(Events.RowInserted<ARInvoice> e)
{
PXEntryStatus entryStatus = e.Cache.GetStatus(e.Row);
if (entryStatus == PXEntryStatus.Inserted)
{
// BQL on SOOrderShipment
}
#endregion
}
}

When the invoice is created you can seek the ShipmentNbr based on the e.Row.RefNbr field

The code above runs when the invoice is created.

3 replies

Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

Hi @scottstanaland12 

 

You have to consider the adapter parameter. Please look into the original Acumatica function:

protected virtual IEnumerable CreateInvoice(PXAdapter adapter)
{
var shipments = adapter.Get<SOShipment>().ToList();

. . .
}

When the call is made on the Shipment screen or through the processing screen, Acumatica always sends the list through the adapter parameter.

 

 


Forum|alt.badge.img+1

Hi ​​​@Leonardo Justiniano  

Thank you for the quick response.  I will give that a try. 

One question, I was using the method of creating an event handler that fires when the ARInvoice record is inserted in the base method.  I assume the adapter.Get<SOShipment>() call will return all rows that were selected on the processing screen.  Is there a way I can associate the generated invoice with the Shipment Nbr?  

 

 

 


Leonardo Justiniano
Jr Varsity II
Forum|alt.badge.img+4

@scottstanaland12 

 

Yes, adapter contains all selected SOShipment records, or 1 record in case of the Shipment screen.

About your question, you can create an RowInserted event in a SOInvoiceEntry extension looking at SOOrderShipment table (InvoiceNbr & ShipmentNbr):

namespace PX.Objects.SO
{
public class SOInvoiceEntry_Extension : PXGraphExtension<SOInvoiceEntry>
{
#region Event Handlers
protected void _(Events.RowInserted<ARInvoice> e)
{
PXEntryStatus entryStatus = e.Cache.GetStatus(e.Row);
if (entryStatus == PXEntryStatus.Inserted)
{
// BQL on SOOrderShipment
}
#endregion
}
}

When the invoice is created you can seek the ShipmentNbr based on the e.Row.RefNbr field

The code above runs when the invoice is created.