4 Replies Latest reply on Jul 6, 2017 9:11 AM by embeco

    Copy Found Set


      I need to write a script to copy a found set of records and change the report number for the copied records.

      PERFORM FIND (original inspection record)

      GOTO RELEATED RECORD (generates a foundset of the photographs related to the above inspection - the cursor lands on the first record)


        DUPLICATE RECORD/REQUEST (duplicates the first record and creates it just below the record that it copied)

        SET FIELD Report Number = 666  (giving the new picture records the report number of the new inspection)

        GO TO NEXT RECORD REQUEST/NEXT EXIT IF LAST (go to the next record in the foundset)

      END LOOP

      My earlier version worked fine: The GOTO RELATED RECORD found the matching records and landed on the first record of the found set. The DUPLICATE copied the first record just below the one it copied and then set it to the new report number, went to the next record (number 2 of the original foundset) and did the same thing over and over which was great each time duplicating the record just before it and placing the new record just below the one it copied.

      The new version (running the same code) the GOTO RELATED RECORD found the matching records and landed on the first record of the found set (so far so good) but when the DUPLICATE RECORD executed, it created the duplicate AT THE END OF THE FOUNDSET. The GOTO NEXT detected that it was at the end of the foundset and exited the script.

      How do I get the DUPLICATE command to create the new record just below the record copied or do I take a whole new approach???

        • 1. Re: Copy Found Set

          A little more than you need, but worth a look?


          • 2. Re: Copy Found Set

            The difference you describe is controlled by whether or not your found set is sorted with the Keep records in sorted order check box selected.


            The first account matches such sorted records. Your more recent experience matches an unsorted found set--where newly created records are then added to the end of the found set.


            I do this kind of loop with unsorted records this way:



                Duplicate record

                Set Field

                Omit Record

                Go to Record/Request/Page [First]

                Omit Record

                Exit Loop If [Get ( FoundCount ) = 0 )

            End Loop


            But you could keep your current code and just sort your records, go to first record before looping through them.

            • 3. Re: Copy Found Set

              Thanks, Beverly, for your prompt reply. You are correct, it is a little more than I need. I came to the same conclusion Phil came up with about the sort order for the file. That will be the simplest way of getting my client back in the field  

              • 4. Re: Copy Found Set

                Thanks for your prompt reply. I came to the same conclusion just as I punched the “Send” button. I do love the Community