Added two Grids to the Customer Location Screen, both error on save saying Location ID cannot be 0
Added two grids to the Customer Locations Screen. The screens work fine up to the point where I hit save. Then it says it cannot set Location ID cannot be empty. So Location ID is not being grabbed by the data view I assume. Â
The Definitions of the two data views are below:Â
namespace LocationTab {   public class CustomerLocationMaint_Extension : PXGraphExtension<CustomerLocationMaint>   {    #region Event Handlers Â
   public PXSelect<InvoiceRatesDetail, Where<InvoiceRatesDetail.locationID, Equal<Current<Location.locationID>>>> InvoiceRates;    public PXSelect<SettlementDetail, Where<SettlementDetail.locationID, Equal<Current<Location.locationID>>>> InvoiceSettlement;
   #endregion   } }
Â
For the data definition in code (table one InvoiceRatesDetail):Â
 #region LocationID    )PXDBInt(IsKey=true)]       DPXParent(typeof(Select<Location, Where<Location.locationID, Equal<Current<InvoiceRatesDetail.locationID>>>>))]    ePXUIField(DisplayName = "Location ID")]    public virtual int? LocationID { get; set; }    public abstract class locationID : PX.Data.BQL.BqlInt.Field<locationID> { }    #endregion
(table two SettlementDetail):
 #region LocationID    nPXDBInt(IsKey=true)]    ePXDBDefault(typeof(Location.locationID))]    PXParent(typeof(Select<Location, Where<Location.locationID, Equal<Current<SettlementDetail.locationID>>>>))]    oPXUIField(DisplayName = "Location ID")]    public virtual int? LocationID { get; set; }    public abstract class locationID : PX.Data.BQL.BqlInt.Field<locationID> { }    #endregion
Â
Error message on save:
Â
Any help would be appreciated
Â
Â
Page 1 / 1
Wrong account - see my response below
@edwardmcgovern97
The original Location DAC also includes BAccountID as part of the primary key.
Try to include BAccountID field in your table definition - with PXDBDefault attribute as well -Â and redefine the Data view as
public PXSelect<InvoiceRatesDetail, Where<InvoiceRatesDetail.bAccountID, Equal<Current<Location.bAccountID>>, And<InvoiceRatesDetail.locationID, Equal<Current<Location.locationID>>>>> InvoiceRates;
Notice the definition of LocationCurrent and Opportunities data views, following a similar structure.
I did not include the bAccountID in the new tables and of course not part of the views because of it (didn’t see Customer ID and it threw me off. Thanks for pointing that out.
Â
I have added to both tables the bAccountIDÂ
and changed the pxparent in both DAC definitions to have where clauses with both baccountid and locationidÂ
Â
 #region bAccountID    PXDBInt(IsKey=true)]    ]PXDBDefault(typeof(Location.bAccountID))]                       PXParent(typeof(Select<Location, Where<Location.bAccountID, Equal<Current<InvoiceRatesDetail.bAccountID>>, And<Location.locationID, Equal<Current<InvoiceRatesDetail.locationID>>>>>))]    cPXUIField(DisplayName = "Customer ID")]    public virtual int? BAccountID { get; set; }    public abstract class bAccountID : PX.Data.BQL.BqlInt.Field<bAccountID> { }    #endregion        #region LocationID    /PXDBInt(IsKey=true)]    ÂPXDBDefault(typeof(Location.locationID))]    BPXParent(typeof(Select<Location, Where<Location.bAccountID, Equal<Current<InvoiceRatesDetail.bAccountID>>, And<Location.locationID, Equal<Current<InvoiceRatesDetail.locationID>>>>>))]    oPXUIField(DisplayName = "Location ID")]    public virtual int? LocationID { get; set; }    public abstract class locationID : PX.Data.BQL.BqlInt.Field<locationID> { }    #endregion
Â
I have updated the views to filter both on baccountid and locationid
Â
 public PXSelect<InvoiceRatesDetail, Where<InvoiceRatesDetail.bAccountID, Equal<Current<Location.bAccountID>>, And<InvoiceRatesDetail.locationID, Equal<Current<Location.locationID>>>>> InvoiceRates;    public PXSelect<SettlementDetail, Where<SettlementDetail.bAccountID, Equal<Current<Location.bAccountID>>, And<SettlementDetail.locationID, Equal<Current<Location.locationID>>>>> InvoiceSettlement;    Â
This time I get both cannot be empty:Â Â
Â
Â
@edwardmcgovern97Â please share the customization package in order to test it locally.
Its the two grids on AR303020 Rates and Settlements
Sorry did not put one of the table scirpts
@edwardmcgovern97Â the issue is related to the definition of the PXDBDefault]Â attribute.
You have it defined as  gPXDBDefault(typeof(Location.bAccountID))]  Â
which, based on the combination of libraries indicated in the class, it’s taking the PX.Objects.CR.Standalone.Location class
Â
However, it should be using PX.Objects.CR.Location instead.
The PXDBDefault attributes should be defined as this:
I am attaching a simplified version of the customization project for your reference.
-----Â
You could see this incorrect defaulting behavior by adding the BAccountID and LocationID columns to the grid. When new lines were being added, the fields remained blank, instead of predefaulting the header values.
-----
Note: It’s likely that PXParent attribute should be adjusted too, but I have not tested this.