Greetings,
I am currently working on my first proper customization and have some trouble with field values.
The plan is to include another fourth addressline in addition to the already existing three addresslines, not only in the Customer-Data but also for use in invoices and other forms.
I went ahead and wrote these two Extensions:
AddressExtension:
using PX.CS.Contracts.Interfaces;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data;
using PX.Objects.Common.Bql;
using PX.Objects.CR.MassProcess;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects;
using System.Collections.Generic;
using System.Diagnostics;
using System;
namespace PX.Objects.CR
{
public class AddressExt : PXCacheExtension<PX.Objects.CR.Address>
{
#region UsrAdressLine4
UPXDBString(50)]
PXUIField(DisplayName="Adresszeile 4")]
public virtual string UsrAdressLine4 { get; set; }
public abstract class usrAdressLine4 : PX.Data.BQL.BqlString.Field<usrAdressLine4> { }
#endregion
}
}
ARAddressExtension:
using PX.CS.Contracts.Interfaces;
using PX.Data.ReferentialIntegrity.Attributes;
using PX.Data;
using PX.Objects.AR;
using PX.Objects.CR;
using PX.Objects.CS;
using PX.Objects;
using System.Collections.Generic;
using System.Text;
using System;
using PX.Data.BQL.Fluent;
namespace PX.Objects.AR
{
public class ARAddressExt : PXCacheExtension<PX.Objects.AR.ARAddress>
{
#region UsrAdressLine4
bPXDBString(50)]
PXUIField(DisplayName="Adresszeile 4")]
public virtual string UsrAdressLine4 { get; set; }
public abstract class usrAdressLine4 : PX.Data.BQL.BqlString.Field<usrAdressLine4> { }
#endregion
}
}
I already got to display these in the correct Screens for Customers, Vendors and Business Accounts, as well as Invoices (sales orders, shipments, purchase orders and bills are to come, as I get it to work with invoices).
I am now in need of a function to set the value from the Address UsrAdressLine4 into the ARAddress UsrAdressLine4 upon selection of a Customer on the Invoices and Memos screen.
It should work like the other standard AddressLine-Fields.
I tried a couple of darylbowmans Solutions from this thread.
I couldn’t get it to work with these Lines:
nPXDefault(typeof(Search<AddressExt.usrAdressLine4,
Where<Address.bAccountID, Equal<Current<ARInvoice.customerID>>>>))]
4PXFormula(typeof(Default<ARInvoice.customerID>))]
nor
;PXDefault(typeof(SearchFor<AddressExt.usrAdressLine4>.
In<SelectFrom<AddressExt>.
Where<Address.bAccountID.IsEqual<ARAddress.customerID>>>))]
Any ideas or pointers?