Maybe create a relationship with a new Person TO where
Project::z_create_firstName = People_check::nameFirst
Project::z_create_lastName = People_check::nameLast
and check with
If [ not IsEmpty ( People_check::primaryKey ) ]
Show Custom Dialog [ "Name already exists" ; … ]
Make sure to auto-Trim() your entry fields.
You could also try a SQL query, but that is not everyone's cup o' tea.
Thanks for your input erolst. Do you have an example for this? It looks like this will only check if the firstname and lastname are unique seprately. It should be the combination of first and last that should be unique
It looks like this will only check if the firstname and lastname are unique seprately.
Is that your considered opinion as an expert, or did you test it empirically?
OK, kidding aside: relationship predicates in FileMaker are combined with a logical AND, i.e. all conditions must be true for a match.
This is a hide condition; for your scripted test, you need to use not IsEmpty().
1 of 1 people found this helpful
1. Why are you doing this the hard way, instead of using a relationship?
2. Your script is hard to follow because there's much redundancy; e.g. you're closing the popover and resetting the globals in 3 places. Since it seems you want to do that in any case, why not do it instantly after launching the script? (and you should add error trapping: if someone launches the script without having both fields filled in, this is all for the birds.
3. If your AND search didn't find a match on two fields, there cannot be a validation error for the uniqueness of both fields combined (if that is what you're doing).
4. You may want to consider the scenario where two people have the same name. What then?
5. You should Trim() the names in the database (via auto-enter) and the input in the globals (in the script); if someone types a blank somewhere, all bets are off.
I suggest (pseudo-code)
If [ inputIsNotOK ]
Dialog [ missing values etc. ]
Set Variables to Trim()med versions of input globals
Set Variable [ $candidateCreated ; False ]
Go to Layout
Perform the Find
If [ error = 401 ]
Create new record with names
If [ error = 504 ]
Set Variable [ $candidateCreated ; True ]
Go to original layout
Dialog [ If [ $candidateCreated ; "createdMessage" ; "alreadyExistsMessage" ) ]
Thanks for the input. My script runs perfectly fine in PRO/advanced, but not in webdirect. The popover hangs in webdirect and resulting in bug. So there must be something that is not sopported in webdirect.
I need to stick to the script intill I get more experimence, I understand mine