Solved

Add UserDefined fields from SOOrder to Shipment

  • 24 March 2023
  • 8 replies
  • 346 views

Userlevel 1
Badge

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.

icon

Best answer by Naveen Boga 25 March 2023, 16:58

View original

8 replies

Userlevel 7
Badge +17

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.

 

 

 

Userlevel 1
Badge

@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.

Userlevel 7
Badge +17

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?

Userlevel 7
Badge +8

@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.

Userlevel 1
Badge

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

Userlevel 7
Badge +17

@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?

 

 

Userlevel 7
Badge +17

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

 

Userlevel 5
Badge +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


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