• JDELIST is celebrating its 20 year anniversary today!
  • Introducing Dark Mode! Switch by clicking on the lightbulb icon next to Search or by clicking on Default style at the bottom left of the page!

Check for duplicates in the grid of Headerless detail form

I have a headerless detail form where users copy records into the grid from a spread sheet or manually enters into the grid. There is a situation where the user could type in the same value twice or could appear twice in the grid while copying records from the spreadsheet. Is there a way to check for duplicates when the user is entering records in the grid or copying records into the grid and set an error as they are entering records instead of waiting for them to hit the OK button. I want to do a validation where when the user enters a record in the grid, it needs to check the previously entered records in the grid to ensure that the same value is not already entered.
Please let me know how I can achieve this.

E1 9.1


Legendary Poster

You can put code into the Grid Event Rules using either the "Row Exited & Changed Inline" or the "Row Exited & Changed Asynch" events.
I do not have a lot of experience on Interactive applications.
I have been trying to do this in the "Row Exited & Changed Asynch" event. I cant get it to work though - It loops and finds itself. I guess I am not using the right system functions.
Could any of you please help me with what code I should be writing to achieve this.

Hi Peter,

Thanks for your response. I now got it to show the error if there is a duplicate.
But now when I go and delete the duplicate line the error does not go away on the other line.
Below is my code

VA evt_szIdentifier2ndItem_LITM = GC ISBN-13
Get Selected Grid Row Number(FC Grid, VA frm_mnCurrentGridRow_MATH01)
Get Max Grid Rows(FC Grid, VA frm_mnMaxGridRows_MATH01)
VA frm_mnRowCount_MATH01 = "1"
While VA frm_mnRowCount_MATH01 is less than or equal to VA frm_mnMaxGridRows_MATH01 And VA frm_mnRowCount_MATH01 is not equal to VA frm_mnCurrentGridRow_MATH01
Get Grid Row(FC Grid, VA frm_mnRowCount_MATH01)
If VA evt_szIdentifier2ndItem_LITM is equal to GC ISBN-13
Set Grid Cell Error(FC Grid, <Currently Selected Row>, <All Columns>, "I75E038")
Set Grid Cell Error(FC Grid, VA frm_mnCurrentGridRow_MATH01, <All Columns>, "I75E038")
Clear Grid Cell Error(FC Grid, <Currently Selected Row>, <All Columns>)
! Clear Grid Cell Error(FC Grid, VA frm_mnCurrentGridRow_MATH01, <All Columns>)
End If
VA frm_mnRowCount_MATH01 = [VA frm_mnRowCount_MATH01]+1
End While

Any help would be greatly appreciated.



Legendary Poster

The code looks good to catch the duplicate and set the error. However when the duplicate row is deleted, the code is not run, because the row has not been changed. Thus the error is not cleared.

You will need to add code to remove the error in a different event, probably Delete Grid Rec Verify-Before.