Jump to content
Server Maintenance This Week. ×

Duplicate a found set of records with a loop


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

Recommended Posts

I have a data base of records I do a search for the found set I need then I try running the following script but it only duplicates one record. What's going wrong? I checked and the records are starting at number one. The only record that gets duplicated is record one. Here is the script.

Loop

Duplicate Record/Request

Go to Record/Request/Page [Next; Exit after last]

End Loop

Any help would be appreciated.

Thanks in advance.

Link to comment
Share on other sites

When a record is duplicated on an unsorted list it is created at the end of the found set of records. FileMaker navigates to the newly created record. You are left at the end of the list after the first record duplication. You need a way to reliably navigate through the entire list despite always bouncing to the newly created record.

Unsort Records

Go to Record/Request/Page[ First ]

Set Variable [ $recordPosn; Value:1 ]

Set Variable [ $foundCount; Value:Get(FoundCount) ]

Loop

Duplicate Record/Request

Set Variable [ $recordPosn; Value:$recordPosn + 1 ]

Exit Loop If [ $recordPosn > $foundCount ]

Go to Record/Request/Page [ $recordPosn; No dialog ]

End Loop

To leave only the duplicates, add these two lines at the end of the script.

Go to Record/Request/Page[ First ]

Omit Multiple Records[No dialog; $foundCount]

Edited by Guest
added Omit original set
Link to comment
Share on other sites

FWIW I think it is preferable to always put the exit loop if statement as the first statement in the loop. Then you know you're never going to trigger the action if the exit condition has been met.

  • Like 1
Link to comment
Share on other sites

  • 5 years later...

This topic is 2931 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.