3 Replies Latest reply on Jul 9, 2013 5:10 PM by dsr1

    Stepping through a found set to duplicate records

    dsr1

      Title

      Stepping through a found set to duplicate records

      Post

           Hi All,

           I wish to duplicate selected records (within a found set), then change the field with the match criteria. My problem is that the found set grows each time I duplicate, even though the new record no longer matches the found set, so the next record is always the first created:

           Eg:

            

           Enter Find Mode

           Set Field [Table::Source_Job_SN; $SourceJobSN]

           Perform Find

           Set Variable [$Steps ; Value; Get(FoundCount)

              Exit Loop If [$Steps <1]

              Duplicate Record / Request

              Set Field [Table::Source_Job_SN; $NewJobSN]

              Commit Records / Request [No dialog]

              Go To Record / Request / Page [Next]

              Set Variable [$Steps ; Value; $Steps -1)

           End Loop

            

           I suspect I'm not using the found set correctly.

            

           PS I just noticed "Exit after Last" which looks like it will save manual counting.

            

           Peter

             

            

            

            

        • 1. Re: Stepping through a found set to duplicate records
          GuyStevens

               Hey Peter.

               You can try this manually first to find out what happens. Best is to do this in a table view layout so you can clearly see what happens.

               First you perform your find. Like you did.

               - Enter Find Mode [Uncheck Pause]
               - Set Field
               - Perform Find

               Then the trick is to make sure your sorting is not going to unintendedly move records around so:

               - Unsort records
               Then
               - Go to Record Request [First]
               - Loop
                 - Duplicate record

                 This makes a duplicate and puts that duplicated record at the back of your found set.

                 - Set Field to change whatever value you want to change in that duplicated record
                 - Omit record. (To remove that record from the found set)
                 - Go To Record / Reuest [First]
                 - Omit Record  ( To remove the one you already duplicated from your found set)
                 - Exit Loop if [ Get (FoundCount ) = 0]
               End Loop

               This is just of the top of my head, so might need some tweaking.


                

          • 2. Re: Stepping through a found set to duplicate records
            dsr1

                 I just realised that the script had not yet created the new master record which supplies the default value for the new duplicated record's find criteria.

                 I'll do the mods, test and update this post soon.

            • 3. Re: Stepping through a found set to duplicate records
              dsr1

                   Thanks Dasaint,

                   My thoughts of "master record" were not relevant anyway.

                   Your "omit" method worked a treat. Nice and simple.

                    

                   Peter