4 Replies Latest reply on Jul 20, 2010 9:32 AM by philmodjunk

    Deleting incomplete records

    ShawnAmann

      Title

      Deleting incomplete records

      Post

      I would like to be able to remove records that are incomplete (i.e. were created by accident and the user does not have access to delete records)

      I'm thinking the script would look something like 

      If(

      field1 = "" or field2 = " etc....

      )

      delete record

      or maybe something like (not really sure how to do these yet)

      Loop 

      go to next field

      get(activefieldcontects) = ""

      Any ideas? Thanks in advance

        • 1. Re: Deleting incomplete records
          ninja

          Howdy Shawn,

          The approaches you describe should work.  I would probably take this approach:

          Make a calc field resulting in number defined as:

          Case ( IsEmpty (Field1) ; 1;

          IsEmpty (Field2) ; 1;

          IsEmpty (Field2) ; 1;

          ...Insert any other criteria here...

          0)

          Then when you want to cull the records, perform a find for "1" in that calc field.  This gives you the option to review the records to confirm deletion (if you want to).  Then you can simply "Delete Found Set" and be done with it.

          • 2. Re: Deleting incomplete records
            philmodjunk

            Either of the above methods can be made to work--though I prefer IsEmpty ( table::Field) to table::Field = "". You could also perform a find for all records with empty fields and then use delete all records (actually deletes the found set).

            Your script might look like this:

            Enter Find Mode[]
            Set Field [table::Field1 ; "="]
            New Record/request
            Set field [table::field2 ; "="]
            new Record/request
            Set field [table::field3 ; "="]
            //and so forth for each field where empty field identifies it for deletion
            set error capture [on]
            Perform Find[]
            Delete All Records[no dialog]

            Using New Record/Request puts the criteria for each empty field on a different request that tells filemaker "find all records where field 1 is empty OR field 2 is empty OR..."

            • 3. Re: Deleting incomplete records
              ShawnAmann

              Thanks for the quick responses!

              Ninja: answer makes sense to my new FM brain :)

              Philmod: whats the purpose of the "=" do? Wouldnt that insert a = into the field and then search for that? Why not sort field to "" to search for blanks?

              Also just for my learning, why would you prefer isempty to = "". A database speed thing, best practice?

              Thanks both so much. Learning tons here. Cool to see so many ways to get the same thing done....

              • 4. Re: Deleting incomplete records
                philmodjunk

                Philmod: whats the purpose of the "=" do? Wouldnt that insert a = into the field and then search for that? Why not sort field to "" to search for blanks?

                Try it and see with a manual find. An = with no data after it has worked as a way for finding records with empty fields for many versions of filemaker.