Skip to main content
Solved

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

  • November 14, 2023
  • 1 reply
  • 330 views

Forum|alt.badge.img

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

Best answer by paengesser82

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

View original
Did this topic help you find an answer to your question?

1 reply

Forum|alt.badge.img+1
  • Varsity I
  • 28 replies
  • Answer
  • November 14, 2023

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings