Question

Save on GridView screen creates additional blank row and attempts to save it

  • 28 December 2023
  • 13 replies
  • 125 views

I have a custom table with a basic GridView screen for entry.  When entering values for the first row and clicking Save, an error is thrown saying that one of the non-nullable fields has a null value.  After some debugging, it appears that the save is trying to save the row I entered, plus a new blank row -- thus, the complaint of the null value. In fact, if I make the field nullable, it actually saves the blank row (blank except for identity field) in the db.  Also, this only happens on the first row entered.  If I add another row and save, it doesn’t happen.  My guess is maybe a table/DAC key issue that makes it want to insert instead of update, but I’ve triple checked my key references.  Does this ring a bell to anyone as something you’ve run across?

Custom Table1 and Table2 have identity keys.  Custom Table2 has a foreign key to Table1 referencing its key field.  Table1 primary key definition:
 

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

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

 

Table2 primary key and foreign key:

 

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

public new static class FK
{
public class LocationBarcode :
CFLocationBarcode.PK.ForeignKeyOf<CFLocationBarcode>
.By<CFLocationBarcode.locationBarcodeID> { }
}

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

[PXDBInt()]
[PXUIField(DisplayName = "Location Barcode", Required = true)]
[PXSelector(...)]
public virtual int? LocationBarcodeID { get; set; }
public abstract class locationBarcodeID : PX.Data.BQL.BqlInt.Field<locationBarcodeID> { }

 


13 replies

Badge +11

Yes, absolutely have encountered this. I’m blanking on how I fixed it.

Badge +11

Could you post your graph? Is this a primary grid?

Userlevel 7
Badge +5

You’ve set the UI to indicate that the LocationBarcodeID field is required but you haven’t set a PXDefault with any instructions around null values.

Badge +11

You’ve set the UI to indicate that the LocationBarcodeID field is required but you haven’t set a PXDefault with any instructions around null values.

That shouldn’t cause an issue though. It just won’t be required.

Graph only contains basics…

public PXSavePerRow<CFLocationTracking> Save;
public PXCancel<CFLocationTracking> Cancel;

[PXImport(typeof(CFLocationTracking))]
public PXSelectOrderBy<CFLocationTracking, OrderBy<Asc<CFLocationTracking.sortOrder>>>
Records;

Only thing on the screen is the grid. It is a Primary skin grid, yes.

Badge +11

I was going to suggest PXSavePerRow, so you’re good there. Odd request, but would you mind posting a screenshot yet entering data in the grid?

@Django, I tried PXDefault, PXDBDefault & PXParent.  It hasn’t helped.

@darylbowman 

 

 

Error: 'Location Barcode' cannot be empty.

Badge +11

Instead of defining the Save and Cancel manually, have you tried including the primary DAC in the graph definition?
 

 : PXGraph<GraphName, DACName>

 

I recall having tried this in the past, but I can’t remember if that’s what fixed it. This will display lots of extra buttons that are unnecessary that you’ll then need to hide if this does actually fix it.

@darylbowman , Thanks, but that didn’t help.

Userlevel 4
Badge +1

@tlanzer54.old 
Can you send DB Script once

Badge +11

@tlanzer54.old - Did you figure this out?

Userlevel 1

I’m experiencing the same behaviour.
I worked out that extra empty row is inserted only if the first field that the user enters is a selector. If user starts with typing the content of a text field extra empty row is not inserted. After some debugging it looks like list of events is: 
As soon as user clicks on magnifying glass of the selector ‘RowInserting’ event is triggered. When user selects a row from selector ‘FieldVerifying’ for the selector field is triggered and straight after ‘RowInserting’ event is triggered. So the 1st ‘RowInserting’ is the one that creates the extra empty row.
If user starts to fill in the record from the a text field events are:
‘FieldVerifying’ for the text field is triggered when field looses focus and straight after ‘RowInserting’ event is triggered 
FYI below is the DAC code for the selector
 

#region BAccountID
[BAccount(DisplayName = "Subcontractor")]
[PXUIField(DisplayName = "Subcontractor", Required = true)]
public virtual int? BAccountID { get; set; }
public abstract class bAccountID : PX.Data.BQL.BqlInt.Field<bAccountID> { }
#endregion

@tlanzer54.old strange coincidence that your barcode is also a selector….
To me it looks like a bug with the selector but maybe I’m missing something somewhere...

Any suggestion appreciated

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