Aldrin Muranganwa
Aldrin Muranganwa

Reputation: 1

Acumatica customization that copies the UDF from sales order to shipment and to the invoice

I am looking for an extension that allows the system to copy user-defined fields from sales order to shipment when I create a shipment and from the shipment to invoice when I create an invoice

I have tried this extension but it says the sales table does not contain the column test field of which its a user-defined field, not a database column

public class SOOrderExt : PXCacheExtension<SOOrder>
{
    [PXDBString(50, IsUnicode = true)]
    [PXUIField(DisplayName = "Test Field")]
    public string UsrTestField { get; set; }
    public abstract class usrTestField : PX.Data.BQL.BqlString.Field<usrTestField> { }
}

public class SOShipmentExt : PXCacheExtension<SOShipment>
{
    [PXDBString(50, IsUnicode = true)]
    [PXUIField(DisplayName = "Test Field")]
    public string UsrTestField { get; set; }
    public abstract class usrTestField : PX.Data.BQL.BqlString.Field<usrTestField> { }
}
public class SOShipmentEntryExt : PXGraphExtension<SOShipmentEntry>
{
    public delegate void PersistDelegate();
    [PXOverride]
    public void Persist(Action del)
    {
        if (Base.Document.Cache.GetStatus((object)Base.Document.Current) == PXEntryStatus.Inserted)
        {
            SOShipLine shipLine = Base.Transactions.Select().FirstTableItems.ToList().FirstOrDefault();
            if (shipLine != null)
            { 
                SOOrder objSOOrder = PXSelect<SOOrder, Where<SOOrder.orderType, Equal<Required<SOOrder.orderType>>,
                    And<SOOrder.orderNbr, Equal<Required<SOOrder.orderNbr>>>>>.Select(Base, shipLine.OrigOrderType, shipLine.OrigOrderNbr);
                if (objSOOrder != null)
                {
                    SOOrderExt orderExt = objSOOrder.GetExtension<SOOrderExt>();
                    SOShipmentExt shipmentExt = Base.Document.Current?.GetExtension<SOShipmentExt>(); 
                    shipmentExt.UsrTestField = orderExt.UsrTestField;
                    Base.Document.Cache.Update(Base.Document.Current);
                }
            }

        }
        del();
    }
}

Upvotes: 0

Views: 57

Answers (1)

Patrick Chen
Patrick Chen

Reputation: 1066

You should try overriding SetShipmentFieldsFromOrder

Upvotes: 0

Related Questions