2 Replies Latest reply on Feb 20, 2014 5:58 AM by CICT

    Looking for methods of adding records (new to filemaker)


      Hello all,


      I run into a common problem, and I would like to know how more experienced developers handle this.


      The situation is this: I am in a layout and I need to add new records to a related table. In a lot of these situations, I dont necessarily want to show all the other records, I just want to add a new record with an "ADD" button or something. I have two options (that I know of):


      #1. I can use a portal - simple, easy, and effective

      With this method though, the problem I have is that if I dont want to show any records in the portal, I only want to use it to create new records, then I have to add a filter that will prevent it from showing records. Ok thats no problem, but then what happens is if the user accidently clicks outside the portal, it commits the record and then it disapears - possibly leaving it with missing information. The user doesnt understand why it disappeared. I need a way to prevent the commit from taking place possibly unless some parameter has been met I guess. I know I can run the callback OnRecordValidate(or something like that) but what do you normally use to check that its complete? Do you set some kind of global variable that changes to true when the user clicks a button?


      #2. I can use a script. - again fairly easy and straight forward

      The problem I find with this method is that, I have to store the information they are entering somewhere. So now on the table in which the context of the layout is, I have to add temp fields to store the entered data, then use that data to create the record in the other table, and then go back and wipe out that data when I return to the layout.


      I am currently using option #2, but I just feel like there should be a way to use portals without the risk of the user accidently committing data. How do you handle this situation?



        • 1. Re: Looking for methods of adding records (new to filemaker)

          The simplest way to trap a record commit is with an OnRecordCommit Script Trigger. The script should use an Exit Script step with a False result. This cancels the record commit.


          (Be sure you leave a way out of the trigger, like a button that says "Save". Otherwise, you'll trap the user in an inescapable situation.)





          • 2. Re: Looking for methods of adding records (new to filemaker)

            .... or set the portal off screen in the right hand 'developers' area' (assuming you're using a more recent version of FM) - put an 'add' icon at the end of your [global] loader fields - attach a script to set the out-of-site portal row to the contents of your loader fields, then clear the loader fields.  No leaving record required.  Would just add an on exit script trigger to clear the globals if the user backs out without creating the record.