Skip to main content

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:

 

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


 

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);
        }


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


Hi @darylbowman 

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

 


 

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.


@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.

 

 


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?


I think I finally cracked this. You can have two keys on a table like this. The key is to enable InitNewRow in the grid Mode:

 


Reply