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
View originalI 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
View originalHi
I think what you are suggesting is a different context, correct me if I am wrong.
Hi
UsrFreeTxt is from SOLine level field OR SO header field?
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.
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?
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();
}
}
Hi,
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
}
}
Enter your username or e-mail address. We'll send you an e-mail with instructions to reset your password.