1 Reply Latest reply on Jul 27, 2014 4:25 PM by philmodjunk

    How do I halt a script if a field value already exists?

    buck_5648798798

      Title

      How do I halt a script if a field value already exists?

      Post

           I'm working on a database that was created in an old version of FM. There are several files, one per table. It has since been upgraded to FM7.

           There is a file for Jobs and one for Invoices.

           I've created a script to create invoices using a number from Jobs.

           The script copies a number from the Jobs file. It then opens the invoice file and launches a script. The invoice file's script creates a new record and pastes the number in the proper field. 

           The problem is that if the number already exists, I end up with a blank record and "INVOICE NUMBER” is defined to contain unique values only. You must enter a unique value.

           How can I tell the script to end if the number already exists?

           Thanks!

        • 1. Re: How do I halt a script if a field value already exists?
          philmodjunk

               "It has since been upgraded to FM7" does that mean that this is the version of Filemaker that you are using? This is a very old version.

               One method is define a global field and set up this relationship:

               Globals::GlobalField = Invoices::Jobnumber

               You can then set GlobalField to the value on a layout based on Globals.

               Not IsEmpty ( Invoices::JobNumber )

               will be true only if the jobnumber already exists so this is a way to look for an existing value before you create a new record with it.