Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 6113 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

I'm trying to write a script that searches for records that match a certain criteria (that's done) Then I want to make a copy of each of those records and change one or two values. I thought I could do this with a loop, but my loop just keeps copying the first record over and over, even though my script says:


Go To First Record

LOOP

   Duplicate Record

   Go To Next Record

   Exit when hit last record from original search (done with variable)

End Loop

Why does this keep copying the first record instead of going to the next record and eventually stopping?

Posted

Its not copying the first record. If is making a copy of the copy. So it looks the same but it isnt.

Also you dont need to do this with a variable. You can use go to record [next]. There is an option to exit the loop after the last record.

To keep your orig found set, try opening a new window to duplicate the record and then close the window right after. Your orig window will keep your orig found set. Therefore, you can go to the next record to duplicate.

Posted

Try this script

Go to Layout [ “Layout #1” ]

Loop

Duplicate Record/Request

Omit Record

Go to Record/Request/Page

[ First ]

Omit Record

Exit Loop If [ Get ( FoundCount ) = 0 ]

End Loop

Posted

John's suggestion (use a new window for the duplicating) and Lee's example (omit as you go - also possible to do in a new window if you want to keep your found set) are both good methods.

I think part of your problem is that FileMaker's Duplicate command behaves differently depending on whether your found set is sorted or not. When it's sorted, the dupe will follow the original, so you can then go to the next record. But when the records aren't sorted, the dupe drops to the bottom of the list. That's where the Exit After Last option would have rescued you.

This topic is 6113 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.