Skip to main content
Solved

How to pass customized field values from Sales Header to shipment Header


Forum|alt.badge.img

Hi Team,

How to pass customized field values from Sales Header to shipment Header?

Currently I overrided “CreateShipmentFromSchedules” to pass the customized field values from Sales Line to Shipment. But i cannot find a way to pass the values for headers.

Could you please help me on this.

Regards,

Ramya

Best answer by Vignesh Ponnusamy

Hi @ramya15,

You can override CreateShipment method in SOOrderEntry graph and add RowPersisting evenhandler to inject the custom value that you need to carry from the SO to Shipment screen.

Following is an example for your reference,

    public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
    {
        #region Event Handlers
        public delegate IEnumerable CreateShipmentDelegate(PXAdapter adapter, Nullable<DateTime> shipDate, Nullable<Int32> siteID, String operation);
        [PXOverride]
        public IEnumerable CreateShipment(PXAdapter adapter, Nullable<DateTime> shipDate, Nullable<Int32> siteID, String operation, CreateShipmentDelegate baseMethod)
        {
            PXGraph.InstanceCreated.AddHandler<SOShipmentEntry>((graphShipmentEntry) =>
            {
                graphShipmentEntry.RowPersisting.AddHandler<SOShipment>((sender, e) =>
                {
                    SOShipment currentShipment = (SOShipment)e.Row;
                    SOShipmentExt currentShipmentExt = currentShipment.GetExtension<SOShipmentExt>();
                    SOOrderExt currentOrderExt = PXCache<SOOrder>.GetExtension<SOOrderExt>(Base.Document.Current);
                    currentShipmentExt.UsrSubConPoAmt = currentOrderExt.UsrSubConPoAmt;
                    var files = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current);
                    PXNoteAttribute.SetFileNotes(graphShipmentEntry.Document.Cache, graphShipmentEntry.Document.Current, files);
                });
            });
            return baseMethod(adapter, shipDate, siteID, operation);
        }
        #endregion
    }

 

Good Luck.!

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

6 replies

praveenpo
Semi-Pro II
Forum|alt.badge.img+3
  • Semi-Pro II
  • 99 replies
  • October 17, 2023

hi @ramya15,

You can copy the value from Sales order to shipment using PXDefault

Here is the sample for copying data from SOline to SOShipline..


#region UsrKNValue1
        [PXDBString(50, IsUnicode = true)]
        [PXDefault(typeof(Search<SOLineExt.usrKNValue1,
                              Where<SOLine.orderType, Equal<Current<SOShipLine.origOrderType>>,
                            And<SOLine.orderNbr, Equal<Current<SOShipLine.origOrderNbr>>,
                             And<SOLine.lineNbr, Equal<Current<SOShipLine.origLineNbr>>>>>>), PersistingCheck = PXPersistingCheck.Nothing)]
        [PXUIField(DisplayName = "Value 1")]
        public string UsrKNValue1 { get; set; }
        public abstract class usrKNValue1 : PX.Data.BQL.BqlString.Field<usrKNValue1> { }
        #endregion
 

Hope this is helpful.


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 59 replies
  • October 17, 2023

Hi @praveenpo,

I want to copy value from SOOrder to SOShipment. (Header to Header). Could you help me on this.

 

Regards,

Ramya 


praveenpo
Semi-Pro II
Forum|alt.badge.img+3
  • Semi-Pro II
  • 99 replies
  • October 17, 2023

Can you please share your SOORder and SOShipment  Extension DAC’s

 


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 59 replies
  • October 17, 2023

@praveenpo ,

Please find below details.

 

namespace PX.Objects.SO
{
    public class SOOrderExt : PXCacheExtension<PX.Objects.SO.SOOrder>
    {

#region UsrSubConPoAmt
        [PXDBDecimal]
        [PXUIField(DisplayName = "^SubCon Po Amt")]
        public virtual Decimal? UsrSubConPoAmt { get; set; }
        public abstract class usrSubConPoAmt : PX.Data.BQL.BqlDecimal.Field<usrSubConPoAmt> { }
        #endregion

}

}

****************************************

namespace PX.Objects.SO
{
    public class SOShipmentExt : PXCacheExtension<PX.Objects.SO.SOShipment>
    {

#region UsrSubConPoAmt
        [PXDBDecimal]
        [PXUIField(DisplayName = "^SubCon Po Amt")]
        public virtual Decimal? UsrSubConPoAmt { get; set; }
        public abstract class usrSubConPoAmt : PX.Data.BQL.BqlDecimal.Field<usrSubConPoAmt> { }
        #endregion

}

}

 

 


Vignesh Ponnusamy
Acumatica Moderator
Forum|alt.badge.img+5

Hi @ramya15,

You can override CreateShipment method in SOOrderEntry graph and add RowPersisting evenhandler to inject the custom value that you need to carry from the SO to Shipment screen.

Following is an example for your reference,

    public class SOOrderEntry_Extension : PXGraphExtension<PX.Objects.SO.SOOrderEntry>
    {
        #region Event Handlers
        public delegate IEnumerable CreateShipmentDelegate(PXAdapter adapter, Nullable<DateTime> shipDate, Nullable<Int32> siteID, String operation);
        [PXOverride]
        public IEnumerable CreateShipment(PXAdapter adapter, Nullable<DateTime> shipDate, Nullable<Int32> siteID, String operation, CreateShipmentDelegate baseMethod)
        {
            PXGraph.InstanceCreated.AddHandler<SOShipmentEntry>((graphShipmentEntry) =>
            {
                graphShipmentEntry.RowPersisting.AddHandler<SOShipment>((sender, e) =>
                {
                    SOShipment currentShipment = (SOShipment)e.Row;
                    SOShipmentExt currentShipmentExt = currentShipment.GetExtension<SOShipmentExt>();
                    SOOrderExt currentOrderExt = PXCache<SOOrder>.GetExtension<SOOrderExt>(Base.Document.Current);
                    currentShipmentExt.UsrSubConPoAmt = currentOrderExt.UsrSubConPoAmt;
                    var files = PXNoteAttribute.GetFileNotes(Base.Document.Cache, Base.Document.Current);
                    PXNoteAttribute.SetFileNotes(graphShipmentEntry.Document.Cache, graphShipmentEntry.Document.Current, files);
                });
            });
            return baseMethod(adapter, shipDate, siteID, operation);
        }
        #endregion
    }

 

Good Luck.!


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • 59 replies
  • October 18, 2023

Hi @Vignesh Ponnusamy ,

Thank you, I will try this.

 

Regards,

Ramya


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