Skip to main content
Solved

Add UserDefined fields from SOOrder to Shipment


Forum|alt.badge.img

I have some user-defined fields in the SOOrder form, when I convert that SO to the Shipment I want that fields to move to the Shipment form. How can I achieve this via customization.

Best answer by Naveen Boga

@tanuj81  If you always have only single order on each shipment. 

The below code will work for you. Please verify.

 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();
        }
    }

 

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

8 replies

Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • March 24, 2023

Hi @tanuj81 Sales Orders screen, UDF field information will be stored into the SOOrderKVExt table and for the Shipment screen, UDF fields are stored into the SOSHipmentKVExt.

  1. Create the UDF fields through screen 
  2. While creating the shipment, fetch the UDF field information from SOOrderKVExt and save to the SOShipmentKVExt table.

 

 

 


Forum|alt.badge.img
  • Author
  • Freshman I
  • 21 replies
  • March 24, 2023

@Naveen Boga sorry but I was referring to the CustomField I created on SalesOrder and Shipment screen UsrFreeTxt.

I think what you are suggesting is a different context, correct me if I am wrong.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • March 24, 2023

Hi @tanuj81  Thanks for clarifying and since you have mentioned about UDF, I was thinking about User Defined Fields.

UsrFreeTxt is from SOLine level field OR SO header field?


aaghaei
Captain II
Forum|alt.badge.img+10
  • Captain II
  • 1206 replies
  • March 24, 2023

@tanuj81 the concept is what @Naveen Boga pointed out. It doesn’t matter what is your source field. In your method or using Row Inserting/Inserted event handlers you can get the source field value and Insert/update the target accordingly. It doesn’t matter if it is Attribute tables, a Table Extension or a Custom field in the DAC extensions.

In your case when Shipment Record is inserted lookup your custom field from Order and update target field accordingly.

if you ask how to do that it’s a different story. Provide your customization code here and we can have a look and help you debug/fine-tune.


Forum|alt.badge.img
  • Author
  • Freshman I
  • 21 replies
  • March 24, 2023

@Naveen Boga  it is a custom field in SOOrder and SOShipment DAC. Not at the line level.


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • March 25, 2023

@tanuj81  Okay, thanks for the clarification.

In the shipments screen, we have a button i.e. ADD ORDER, so that the user can add multiple Sales Orders to a single shipment, in this case, how are you displaying this field?

 

 


Naveen Boga
Captain II
Forum|alt.badge.img+19
  • Captain II
  • 3417 replies
  • Answer
  • March 25, 2023

@tanuj81  If you always have only single order on each shipment. 

The below code will work for you. Please verify.

 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();
        }
    }

 


andriikravetskyi35
Jr Varsity I
Forum|alt.badge.img+1

Hi,

  • first you need create DAC for user defined fields table, because Acumatica source code doesn’t have it.
  • second you need create View object with rules that pipeline shipment and soOrder by guid.

So the main logic is on example, select from SOOrderUsrDefinedFieldsView.Select() - give you access to data in DB in SOOrderKvExt table:

namespace test
{
  public SOShipEntryExt : PXGraphExtension<SOShipmentEntry>
    {
    public static bool IsActive()=>true;

      SelectFrom<SOOrderKvExt>.Where<  "here add bql rules to bound guid SOOrderKvExt.RecordID with Shipment" >.View SOOrderUsrDefinedFieldsView;

    }


  [Serializable]
  [PXCacheName("SOOrderKvExt")]
  public class SOOrderKvExt : IBqlTable
  {
    #region RecordID
    [PXDBGuid(IsKey = true)]
    [PXUIField(DisplayName = "Record ID")]
    public virtual Guid? RecordID { get; set; }
    public abstract class recordID : PX.Data.BQL.BqlGuid.Field<recordID> { }
    #endregion

    #region FieldName
    [PXDBString(50, IsKey = true, InputMask = "")]
    [PXUIField(DisplayName = "Field Name")]
    public virtual string FieldName { get; set; }
    public abstract class fieldName : PX.Data.BQL.BqlString.Field<fieldName> { }
    #endregion

    #region ValueNumeric
    [PXDBDecimal()]
    [PXUIField(DisplayName = "Value Numeric")]
    public virtual Decimal? ValueNumeric { get; set; }
    public abstract class valueNumeric : PX.Data.BQL.BqlDecimal.Field<valueNumeric> { }
    #endregion

    #region ValueDate
    [PXDBDate()]
    [PXUIField(DisplayName = "Value Date")]
    public virtual DateTime? ValueDate { get; set; }
    public abstract class valueDate : PX.Data.BQL.BqlDateTime.Field<valueDate> { }
    #endregion

    #region ValueString
    [PXDBString(256, IsUnicode = true, InputMask = "")]
    [PXUIField(DisplayName = "Value String")]
    public virtual string ValueString { get; set; }
    public abstract class valueString : PX.Data.BQL.BqlString.Field<valueString> { }
    #endregion

    #region ValueText
    [PXDBString(IsUnicode = true, InputMask = "")]
    [PXUIField(DisplayName = "Value Text")]
    public virtual string ValueText { get; set; }
    public abstract class valueText : PX.Data.BQL.BqlString.Field<valueText> { }
    #endregion
  }
}

 


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