Skip to main content

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

 

 

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:

gPXDBDefault(typeof(PX.Objects.CR.Location.bAccountID))]

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.


Reply