7 Replies Latest reply on Feb 26, 2015 4:35 PM by philmodjunk

    Help with creating duplicate records



      Help with creating duplicate records


      I have Filemaker Pro 13.  I have a database of people who fill out a form annually that I track if they have turned it back in to me.    I want to pull up a particular year's report (2013) for anyone who is active (Y) and duplicate the records, change the year to 2014 and then I can go in and put a (Y) in the field if it has been turned in.

      How do I do this?

      One other question:  I have a Tab Control box with a portal in it.  On the portal is a button to open up the detail to the portal row that you have selected.  This detail is in another layout where you can edit or view info on this particular person.  I have a button to close this layout but it takes me back to the first person in my database rather than the person whose portal record I was editing, which could be person 11.  I want to close the portal layout and return to the person I was just on.  What are the steps in the script for me to get this to work right?

        • 1. Re: Help with creating duplicate records

          Question 2 first.

          I don't understand the tab control box w/ portal, and goes back to the first person.  Are you saying the portal resets to the first record in the portal, or the Main record you were on goes to the first Main record?

          What I would do is open the detail layout in a new modal window.  After thoroughly testing, I would remove all navigation on this layout and add a close window button, that just closes the window. Then after you are done editing on the detail layout, closing this window puts you back where you started........if I understand your question correctly.

          Question 1

          This would require a script with a loop.........and testing on a copy of the database.

          Assuming the report is basically a find of all the people who turned in 'the form'.  Do this find on the layout that contains each form.  Then basically

          Go to Record [First] //usually this isn't required after a find because it puts you on the first record


             Duplicate Record

             Set Field [YourTable::YearField; Year ( Get ( CurrentDate ) )

             Set Field [the one you want to put a 'Y" into]

             Hide Record (I think this is needed, to prevent from duplicating the duplicate.  It may invoke a commit records dialog, which can be suppressed with starting the script with Set Error Capture script step)

             Go to Record [Next;exit after last]

          End Loop

          But test on a sample DB first

          • 2. Re: Help with creating duplicate records

            In an unsorted found set, duplicate record creates a new record at the end of your found set. This becomes your current record so Go to record [next ; exit after last] won't work.

            Instead, do it this way:

               Exit Loop If [ Not Get ( FoundCount ) ]
               Duplicate Record
               Set FIeld
               Omit Record
               Go to Record/request/page [first]
               Omit Record
            End Loop

            This leaves you with a blank layout due to a found set of zero records. But you can then perform a find for all records with the data you just entered via the set field step to pull up just the list of newly created records.

            • 3. Re: Help with creating duplicate records

              I will try your method in response to my original question on the duplication issue.

              To answer your question about the portal, I have a screen shot of the main screen and then a screen shot of the detail screen which is accessed by pressing the button on the portal row.  When I close the detail screen, it takes me back to record number 1 of the database rather than the record that the portal I was on.  In the screen shot, I am showing you record #9.  When I close the detail screen, it takes me to record #1.

              • 4. Re: Help with creating duplicate records

                So I have not heard from anyone on my dilemma regarding the button and explanation above.


                • 5. Re: Help with creating duplicate records

                  There are multiple possibilities. Best guess is that one of the several layout changes is tripping a script trigger that performs a script taking you back to the first record of the layout's found set.

                  On Layout Enter, OnLayoutExit, OnRecordLoad, OnObjectEnter are just a few of the triggers that a change in layouts can trip.

                  But if your return button performs a script, that scipt could also contain code that changes records.

                  If you have FileMaker Advanced, enable the script debugger just before clicking return and then step through any script that appears in the debugger. If a script trigger is being tripped, you'll see it's script pop up in the debugger.

                  • 6. Re: Help with creating duplicate records

                    So, if I do have a script that takes me to first record and I want to add code to the button to get me to a particular record, what is the code?

                    • 7. Re: Help with creating duplicate records

                      The code is to not run the script that takes you to the first record when this button is clicked. Go To Layout should be all that is needed to return both to the layout and your current record on that layout. But is some script is run, either from the button click or one of the layout changes that changes the current record, you'll need to take steps to prevent that code from being executed.