April 5, 200322 yr 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....
April 5, 200322 yr 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.
April 5, 200322 yr 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.
April 5, 200322 yr 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.
April 5, 200322 yr Author Russ, thanks! This is exactly what I needed. I overlooked the functionality of the "Omit Record".
May 8, 200322 yr 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.)
Create an account or sign in to comment