Check for duplicates on gridadd

This public forum is for user-to-user discussions of ASPMaker. Note that this is not support forum.

Check for duplicates on gridadd

Postby JAW » Tue Nov 28, 2017 8:10 am

Hello,
In my scheduling system I am using Grid Add. When a record is entered I need to check and see if the person has already been scheduled for the date selected. I use this code in the Row_Inserting Server Event and in Row_Updating Server Event and it works perfectly if adding one record or editing a record. However, it does not catch it in the List page when using Grid Add. Where can I add the same logic that I have in Row_Inserting/Updating that will catch it when adding records in Grid Add?

Thanks
JW
JAW
 
Posts: 65
Joined: Tue Nov 20, 2012 8:26 pm

Re: Check for duplicates on gridadd

Postby motfs » Tue Nov 28, 2017 11:37 am

Simply enable the option "Check duplicate". Read the help file topic: Field Setup -> Edit Tag -> Check duplicate for more detail.
motfs
 
Posts: 710
Joined: Tue Sep 08, 2015 4:55 pm

Re: Check for duplicates on gridadd

Postby JAW » Wed Nov 29, 2017 6:27 pm

Thanks for the response but that won't work for my application. I guess I didn't explain very well. I have a view in a MySQL database that has the UserID and Date. I need to check to make sure the user is not scheduled for a date when a record is added. This works if I add one record at a time using Row_Inserting but I need it to check when Grid Add is used.

Regards,
JW
JAW
 
Posts: 65
Joined: Tue Nov 20, 2012 8:26 pm

Re: Check for duplicates on gridadd

Postby Webmaster » Thu Nov 30, 2017 10:52 am

Use the Grid_Inserting server event. Refer help file topic: Server Events and Client Scripts for an example.
Webmaster
 
Posts: 10731
Joined: Fri Aug 06, 2004 5:59 pm

Re: Check for duplicates on gridadd

Postby JAW » Sat Dec 02, 2017 12:57 am

Hello,
Thanks for the response. I tried to use the code in Grid_Inserting as suggested but I got an error that rsnew("<FieldName>") can not be used. What would be the proper syntax for rsnew("<FieldName>") when using Grid_Inserting?

Thanks
JW
JAW
 
Posts: 65
Joined: Tue Nov 20, 2012 8:26 pm

Re: Check for duplicates on gridadd

Postby Webmaster » Sat Dec 02, 2017 10:51 am

As per the help file:

Function Grid_Inserting()
Dim rsnew, sum
rsnew = CurrentPage.GetGridFormValues() ' Get the form values of the new records as an array of Dictionary objects
sum = 0
For i = 0 To UBound(rsnew) ' Loop through the new records
sum = sum + CInt(rsnew(i)("Percentage"))
Next
If sum < 100 Then
' To cancel, set return value to False
Page.FailureMessage = "The total of percentages must be 100."
Grid_Inserting = False
Else
Grid_Inserting = True
End If
End Function
Webmaster
 
Posts: 10731
Joined: Fri Aug 06, 2004 5:59 pm


Return to General Discussion (ASPMaker)