Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

duplicate fields

Featured Replies

  • Newbies

I am very new to scripting and I tried to get this question answered before, but I don't think I worded it right. Here goes, I have 6 text fields that a user enters data into. The user then pushes a button and this sets off a script that takes parts of this data and concatenates a new unique name that is then entered into another field. What I am trying to do is to take this new unique field name and have it compared to the unique field name in other records in the database. Im basically looking for duplicates so if there is a duplicate, I want the user to be immediately warned of this and prevented from using this already existing name. I know I can have some form of validation using the options under "Define Fields" but I need the validation to happen in a script. The script has some functions built into that lock the data so it cannot be changed later. If I use validation from Define Fields it halts the script, which I am trying to avoid. I know you can do a find to search for an exact match but I do not know how to integrate this into the script. How do I get FM to compare the current unique name field to the fields in existing records and have it respond if a match is found. Like I said before Im really new to this (I've only been using the program for about a week) so any help would be greatly appreciated.

Many thanks!

You might get the solution even w/out scripting.

First of all, create a self relationship. That means you create a relationship like this: name_dbase1::name_field1=name_dbase1::name_field1, so both key fields are the same. Then create a calculated field which shows the number of fields.

If the number > 1 you can show an alert or do sth else.

Hope it will work.

Matthias

What Matthias has described is, that you create a relationship of the name field back to itself. A calc field can then be defined to equal the count of that field. Place this on a layout and see what happens when there is more than one record with a certain name--See?

Your script can check for this condition. Alternately, another calc field can be defined to show an error message on the screen as soon as the count field shows that a duplicate exists -- no script required.

You had a problem with validation failures interrupting your script, but this is what 'error capture' is for. Turn it on within a script, and no error from that point on will even cause an alert. At the point where the validation problem occurs, use an If statement to check whether Status (CurrentError) is from 500 to 509 (the codes for failed validations -- see FM Help). If no error, this function returns a zero.

But don't underestimate the value of Matthias' solution.

  • Author
  • Newbies

Thanks for the reply. I will give them all a try and see which works best for me. Once again thanks a bunch.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.