Solved

Primary grid only saves last entered record

  • 5 June 2023
  • 7 replies
  • 107 views

Badge +11

I have built a custom screen with a primary grid:

When I enter two or more items into the list and save, only the last item is saved:

 

Why?

 

DAC:

[Serializable]
[PXCacheName("IN Fulfillment Warehouse", PXDacType.Catalogue)]
[PXPrimaryGraph(typeof(INFulfillmentSiteMaint))]
public class INFulfillmentSite : IBqlTable
{
public static class FK
{
public class Site : INSite.PK.ForeignKeyOf<INFulfillmentSite>.By<siteID> { }
}

#region CountryID
[PXDBString(100, IsKey = true, IsUnicode = true)]
[Country]
[PXUIField(DisplayName = "Country")]
[PXDefault("US", PersistingCheck = PXPersistingCheck.Nothing)]
public virtual string CountryID { get; set; }
public abstract class countryID : PX.Data.BQL.BqlString.Field<countryID> { }
#endregion

#region StateID
[PXDBString(50, IsKey = true, IsUnicode = true, InputMask = ">CC")]
[State(typeof(countryID))]
[PXDefault]
[PXUIField(DisplayName = "State")]
public virtual string StateID { get; set; }
public abstract class stateID : PX.Data.BQL.BqlString.Field<stateID> { }
#endregion

#region SiteID
[Site(false)]
[PXDefault]
[PXParent(typeof(FK.Site))]
public virtual int? SiteID { get; set; }
public abstract class siteID : PX.Data.BQL.BqlInt.Field<siteID> { }
#endregion
}

Graph:

public class INFulfillmentSiteMaint : PXGraph<INFulfillmentSiteMaint>
{
public PXCancel<INFulfillmentSite> Cancel;
public PXSavePerRow<INFulfillmentSite> Save;
// also tried public PXSave<INFulfillmentSite> Save;

public PXSelect<INFulfillmentSite> MasterView;

}

ASPX:

 

icon

Best answer by aaghaei 6 June 2023, 09:43

View original

7 replies

Userlevel 7
Badge +5

What are your grid settings for DataSourceID, SkinID, and SyncPosition?

Userlevel 7
Badge +8

 

for SavePerRow include your surrogate key field as well

public PXSavePerRow<INFulfillmentSite, INFulfillmentSite.myInternalID> Save;

 

and also define your DAC PK like

        public class PK : PrimaryKeyOf<INFulfillmentSite>.By<countryID, stateID>
        {
            public static INFulfillmentSite Find(PXGraph graph, string countryID, string stateID) => FindBy(graph, countryID, stateID);
        }

Userlevel 7
Badge +17

Hi @darylbowman  It might be an issue with the KEYS. Possible to share the customization project?

Userlevel 4
Badge +1

Hi @darylbowman 

Can you give the Identity column to grid DAC and Table.

 

Badge +11

 

for SavePerRow include your surrogate key field as well

public PXSavePerRow<INFulfillmentSite, INFulfillmentSite.myInternalID> Save;

 

and also define your DAC PK like

        public class PK : PrimaryKeyOf<INFulfillmentSite>.By<countryID, stateID>
        {
            public static INFulfillmentSite Find(PXGraph graph, string countryID, string stateID) => FindBy(graph, countryID, stateID);
        }

In my understanding of a surrogate key, I don't have one. My keys are Country ID and State ID.

 

Hi @darylbowman  It might be an issue with the KEYS. Possible to share the customization project?

Yeah, I'll share it later.

 

Hi @darylbowman 

Can you give the Identity column to grid DAC and Table.

I'm sorry, but I don't understand the question.

Userlevel 7
Badge +8

@darylbowman those are your natural keys. the surrogated keys are those you add for referential purposes mostly Identity Columns (Like PMTask.TaskID) or Guid (like CRQuote.QuoteID). Basically, you only have one Key field (aside from CompanyID in Acumatica Case).

Without the Surrogate keys, it also will work. When it is saving only one, it means the platform can not identify your keys and assumes all records have the same key so start updating them.

 

 

Badge +11

That was my understanding of keys. I’m not sure why my keys definition would have been confusing the system, but I went to a one-key model instead and I believe it is saving all records now.

I do have one additional issue, which is, when adding several records, upon save, I always get an error about fields being empty, and it is due to one additional row being added upon save no matter of how I use the UI. There is no empty rows when I click save, and there is immediately after.

Is this normal for this kind of view?

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved