Solved

Add custom field as column to Process Shipments screen via custom DataView

  • 14 November 2023
  • 1 reply
  • 126 views

Userlevel 4
Badge

Hi,

I am trying to add a new custom checkbox field as a grid column in the Process Shipments screen called UsrRequiresInvoices, and this custom field resides in the BAccountExt DAC.

 

I imagine I would need to create a custom DataView that pulls in this field, but I wasn’t sure if I needed to structure it in a certain way to ensure the Process Shipments screen still functions as expected.

 

The image below shows how the custom field is currently sitting in the Customers screen. The reason for this field is to identify customers that only want the final shipment invoice to be sent to them without receiving a Shipment Confirmation beforehand.

 

If it is possible to add this custom field as a column via a custom DataView, what would be the best way to structure it?

 

Let me know if I can provide any further information on this.

 

Kind regards,

Andrew

icon

Best answer by paengesser82 15 November 2023, 00:56

View original

1 reply

Userlevel 4
Badge +1

The way I’d do it is to create a DAC extension for SOShipment with an unbound field for Requires Invoices, then populate that field in a SOInvoiceShipment graph extension when the records are fetched.
Here is the code for the DAC

using PX.Data;
using PX.Objects.SO;
using PX.Data.BQL;

// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOShipmentExt : PXCacheExtension<SOShipment>
{
[PXBool]
[PXUIField(DisplayName = "Requires Invoices")]
public bool? UsrRequiresInvoices { get; set; }
public abstract class usrRequiresInvoices : BqlBool.Field<usrRequiresInvoices> { }
}

 

Here is the code for the Graph

using PX.Data;
using PX.Objects.SO;
using PX.Objects.CR;
using Mapadoc;
using System.Collections;

// Acuminator disable once PX1016 ExtensionDoesNotDeclareIsActiveMethod extension should be constantly active
public class SOInvoiceShipment_Extension : PXGraphExtension<SOInvoiceShipment>
{
public static bool IsActive() => true;

public IEnumerable orders()
{
foreach (var record
in Base.orders())
{
SOShipment shipment = PXResult.Unwrap<SOShipment>(record);
BAccount bAccount = BAccount.PK.Find(Base, shipment.CustomerID);

SOShipmentExt shipmentExt = Base.Caches[typeof(SOShipment)].GetExtension<SOShipmentExt>(shipment);
BAccountExt bAccountExt = bAccount.GetExtension<BAccountExt>();

shipmentExt.UsrRequiresInvoices = bAccountExt.UsrRequiresInvoices;
yield return shipment;
}
}
}

Since the field is apart of a DAC extension for SOShipment you should be able to add it to the Process Shipment screen via the customization editor in the same way you can add normal fields.
And here is a link to a previous question which I based my answer off of


If you run into any issues or have any questions let me know!
Philip Engesser

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