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

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

Recommended Posts

Posted

I need to duplicate a set of found records and replace a field in the new duplicate set of records

with a certain value. I'm a little confused on how my logic would be to approach this.

I do a find that will give me all the records that I need to duplicate. Begin a loop that starts at the first found record, duplicate this record and then change the required field of the new record. However in my loop, if I say next record, there is no record to go to next since I'm already at the last record (the newly duplicated record)....

Below is my script:

Enter Find Mode[]

Set Field["nl_refnum" "NC:g_nlrefnum"]

Perform Find [Replace Found Set]

Go to Record Record/Request/Page [First]

Loop

Duplicate Record/Request

Set Field["nl_refnum" "NC:g_dMajornlrefnum"]

Go to Record Record/Request/Page[Next, Exit After Last]

End Loop

Any ideas....

Posted

Use this script to duplicate a found set of records. You need to create a text field "Is This a Duplicate" if you want the duplicates marked. If you want to assign a certain value to a field in the duplicate records, then immediately after the Set Field step is the place to do it.

Replace[No Dialog,Is This a Duplicate,"No"]

Unsort

Go To Record/Request/Page [First]

Loop

. Exit Loop If[status(CurrentFoundCount)=0]

. Duplicate Record/Request

. Set Field [is This a Duplicate,"Yes"]

. Omit Record

. Go to Record/Request/Page [First]

. Omit Record

End Loop

Show All Records

Then, if you want to find the duplicate records you just created, do a Find for "Yes" in the "Is This a Duplicate" field.

Remember, when you duplicate a record, things like auto-entered serial numbers will not be the same as the original record, they will be new.

The logic of this is that, in the unsorted condition, FMP placed duplicates at the end of the record set. The loop is creating duplicates, omitting them, then omitting the first record and going back to the start of the record set - progressively reducing the set until no more records remain to be duplicated.

Posted

For some reason, Filemaker has the functionality using Applescript to duplicate a found set of records with a single step. I'll never understand why they didn't make it as easy using Scriptmaker.

Posted

i prefer using an export -> import routine over duplicating records manually. This way i can selectively update auto-entered values, record creation dates etc. With 1000nds of records it is also faster.

  • 1 month later...
Posted

Actually, I modified the script to replace

Set Field [is This a Duplicate, "Yes"]

to actually update the duplicated field in question to the new (unique) data. Saves a bit of extra scripting and works for me. (I realize that this may not be the best solution for all.)

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