Search code examples
acumaticaacumatica-kb

blank row being added on insert


I have a very simple Maint page, it has no events

    public PXCancel<RCDistributorSalesStat> Cancel;
    public PXSave<RCDistributorSalesStat> Save;

    public SelectFrom<RCDistributorSalesStat>.View Records;

and everytime I save the first record entered I get an error and it has added a second blank line and throws errors that required fields are missing. I found a similar question to this on here about having multiple ISKey set, though I only have one.

        #region DistributorSalesStatID
        [PXDBIdentity(IsKey = true)]
        public virtual int? DistributorSalesStatID { get; set; }
        public abstract class distributorSalesStatID : PX.Data.BQL.BqlInt.Field<distributorSalesStatID> { }
        #endregion

        #region InventoryID
        [StockItem(Visibility = PXUIVisibility.SelectorVisible, DescriptionField = typeof(InventoryItem.inventoryCD), Enabled = true)]
        [PXRestrictor(typeof(Where<InventoryItem.baseUnit.IsEqual<BQLConstants.Straw>>), null)]
        [PXForeignReference(typeof(Field<inventoryID>.IsRelatedTo<InventoryItem.inventoryID>))]
        public virtual int? InventoryID { get; set; }
        public abstract class inventoryID : PX.Data.BQL.BqlInt.Field<inventoryID> { }
        #endregion

        #region StatisticDate
        [PXDBDate()]
        [PXUIField(DisplayName = "Statistic Date")]
        public virtual DateTime? StatisticDate { get; set; }
        public abstract class statisticDate : PX.Data.BQL.BqlDateTime.Field<statisticDate> { }
        #endregion

        #region CustomerID
        [CustomerActive(
            //typeof(Search<BAccountR.bAccountID, Where<True, Equal<True>>>),
            Visibility = PXUIVisibility.SelectorVisible,
            DescriptionField = typeof(Customer.acctName),
            Filterable = true) ]
        //[CustomerOrOrganizationInNoUpdateDocRestrictor]
        [PXForeignReference(typeof(Field<RCDistributorSalesStat.customerID>.IsRelatedTo<PXAccess.BAccount.bAccountID>))]
        public virtual int? CustomerID { get; set; }
        public abstract class customerID : PX.Data.BQL.BqlInt.Field<customerID> { }
        #endregion

        #region CustomerLocationID
        [LocationActive(typeof(Where<Location.bAccountID, Equal<Current<customerID>>,
                And<MatchWithBranch<Location.cBranchID>>>),
            DescriptionField = typeof(Location.descr),
            Visibility = PXUIVisibility.SelectorVisible)]
        [PXDefault(typeof(Coalesce<Search2<BAccountR.defLocationID,
                InnerJoin<CRLocation, On<CRLocation.bAccountID, Equal<BAccountR.bAccountID>, And<CRLocation.locationID, Equal<BAccountR.defLocationID>>>>,
                Where<BAccountR.bAccountID, Equal<Current<customerID>>,
                    And<CRLocation.isActive, Equal<True>,
                        And<MatchWithBranch<CRLocation.cBranchID>>>>>,
            Search<CRLocation.locationID,
                Where<CRLocation.bAccountID, Equal<Current<customerID>>,
                    And<CRLocation.isActive, Equal<True>, And<MatchWithBranch<CRLocation.cBranchID>>>>>>))]
        [PXForeignReference(
            typeof(CompositeKey<
                Field<customerID>.IsRelatedTo<Location.bAccountID>,
                Field<customerLocationID>.IsRelatedTo<Location.locationID>
            >))]
        public virtual int? CustomerLocationID { get; set; }
        public abstract class customerLocationID : PX.Data.BQL.BqlInt.Field<customerLocationID> { }
        #endregion

        #region SalesAmount
        [PXDBDecimal()]
        [PXUIField(DisplayName = "Sales Amount")]
        public virtual Decimal? SalesAmount { get; set; }
        public abstract class salesAmount : PX.Data.BQL.BqlDecimal.Field<salesAmount> { }
        #endregion

        #region SalesUnits
        [PXDBInt()]
        [PXUIField(DisplayName = "Sales Units")]
        public virtual int? SalesUnits { get; set; }
        public abstract class salesUnits : PX.Data.BQL.BqlInt.Field<salesUnits> { }
        #endregion

        #region QuantityOnHand
        [PXDBInt()]
        [PXUIField(DisplayName = "Quantity On Hand")]
        public virtual int? QuantityOnHand { get; set; }
        public abstract class quantityOnHand : PX.Data.BQL.BqlInt.Field<quantityOnHand> { }
        #endregion

I am unsure what is causing the unwanted row to try and persist.


Solution

  • I have changed my keys around, I removed my IsKey on the PXDBIdentity and set two other fields as the key in the DAC and the DB. That seems to have the desired effect as no blank row gets created during Save. Upon further testing it appears that for our listview page I was missing "px:Selector" rows inside of my RowTemplate in my Grid.