Overwriting ShipAddressID and ShipContactID in Shipments screen
Hi there,
Â
I am trying to override the Ship-to-Address and Ship-to-Contact details by making them automatically filled when I select Customer from a custom field in Shipments screen.
Â
Further digging into this shown that the details is referencing from ShipAddressID and ShipContactID which is being referenced from CustomerID on the header. However for Transfer, the Customer selector on the header will be hidden and from SQL, it shows that the Customer is pointing to itself.
Â
How do I get the ShipAddressID and ShipContactID to be referenced from the custom Customer field instead?
Page 1 / 1
Hi @ericklasimin61Â For the Customer ShipAddressID and ShipContactID, please refer the Location table.Â
Here is the screenshot.
Â
Hi @Naveen Boga , so I managed to populate the custom field UsrShipAddressID based on your recommendation.
My Extension:
public class SOShipmentExt : PXCacheExtension<PX.Objects.SO.SOShipment> Â Â { Â Â Â Â #region UsrCustomerID Â Â Â Â CustomerActive(DescriptionField = typeof(Customer.acctName))] Â Â Â Â PXUIField(DisplayName = "Customer ID")] Â Â Â Â ]PXDefault(PersistingCheck = PXPersistingCheck.Nothing)]
    public virtual int? UsrCustomerID { get; set; }     public abstract class usrCustomerID : PX.Data.BQL.BqlInt.Field<usrCustomerID> { }     #endregion
    #region UsrShipAddressID     gPXDBInt]     rPXUIField(DisplayName = "Ship Address ID")]     lPXFormula(typeof(Selector<SOShipmentExt.usrCustomerID, Location.defAddressID>))]
    public virtual int?  UsrShipAddressID { get; set; }     public abstract class usrShipAddressID : PX.Data.BQL.BqlInt.Field<usrShipAddressID> { }     #endregion
    #region UsrShipContactID     dPXDBInt]     ÂPXUIField(DisplayName = "Ship Address ID")]     /PXFormula(typeof(Selector<SOShipmentExt.usrCustomerID, Location.defContactID>))]
    public virtual int? UsrShipContactID { get; set; }     public abstract class usrShipContactID : PX.Data.BQL.BqlInt.Field<usrShipContactID> { }     #endregion   }
Â
My Event Handler:
  public class SOShipmentEntry_Extension : PXGraphExtension<SOShipmentEntry>   {    #region Event Handlers     protected void SOShipment_UsrCustomerID_FieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)      {        var row = (SOShipment)e.Row;        if (row != null)        {          SOShipmentExt sOShipmentExt = row.GetExtension<SOShipmentExt>();          SOShipment sOShipment = SOShipment.PK.Find(Base, row.ShipmentNbr);          sOShipmentExt.UsrShipAddressID = sOShipment.ShipAddressID;        }      }    #endregion   } }
Â
However, how should I override the existing ShipAddressID and UsrShipAddressID and ultimately change the address details?
Sorry @Naveen Boga , the above code indeed managed to populate the UsrShipAddressID but it follows the document CustomerID, not UsrCustomerID. As for UsrCustomerID, I can’t seem to change the value to something else since it will always go back to the initial value.Â
Hi @Naveen Boga , I managed to populate the Ship-to-Contact and Ship-to-Address fields by using the following code:
Â
My DAC Extension:
public class SOShipmentExt : PXCacheExtension<PX.Objects.SO.SOShipment> { #region UsrCustomerID
CustomerActive(DescriptionField = typeof(Customer.acctName))] PXUIField(DisplayName = "Customer ID")] PXDefault(PersistingCheck = PXPersistingCheck.Nothing)] public virtual int? UsrCustomerID { get; set; } public abstract class usrCustomerID : PX.Data.BQL.BqlInt.Field<usrCustomerID> { }
#endregion
#region UsrShipAddressID
PXDBInt()] PXUIField(DisplayName = "Ship Address ID")] public virtual Int32? UsrShipAddressID { get; set; } public abstract class usrShipAddressID : PX.Data.BQL.BqlInt.Field<usrShipAddressID> { }
#endregion
#region UsrShipContactID
PXDBInt()] PXUIField(DisplayName = "Ship Contact ID")] public virtual Int32? UsrShipContactID { get; set; } public abstract class usrShipContactID : PX.Data.BQL.BqlInt.Field<usrShipContactID> { }
#endregion }
Â
My Graph Extension:
public class SOShipmentEntryExt : PXGraphExtension<SOShipmentEntry> { #region Event Handlers
Once the document has been saved and I switched to another document, I am unable to access back the previous document that has been saved and it returns below errors:
Â
If the selected Customer ID doesn’t have any data in SOShipmentAddress or SOShipmentContact, then it won’t allow me to select the customer. Ideally, I should be able to select the customer and the fields should be auto populated with address details from Address table.
I would appreciate any help since I’m getting really close to solving this.
Hi @ericklasimin61 have you been able to resolve your issue or do you still need assistance from @Naveen Boga ? Thank you!
Hi @Chris Hackett , I managed to solve one of the issues by implementing a workaround on them:
I nulled both UsrShipAddressID and UsrShipContactID fields once the method to populate the Address and Contact details has been executed.
Still not resolved. I would welcome any assistance on this.