December 7, 200421 yr Hi Everyone. I am on the verge of being an Intermediate FileMaker user but am having a problem on one simple script: I have a client database listing all of my clients. Sometimes I need to duplicate a client record depending on certain aspects of their account. Is there any way to duplicate a record using the ScriptMaker? For instance, if I had field called "copy" and, entered a value of 4, is it possible to duplicate that record four times at the touch of a button. Also, say I have 5 records that each need to be duplicated a different number of times. How can/would I accomplish this? Thanks very much for your help. Any guidance is much appreciated.
December 7, 200421 yr For a single record. Set Field [globalcopy, copy] Set Field [copy, ""] Loop Duplicate Record/Request Set Field [globalcopy, globalcopy - 1] Exit Loop If [not globalcopy] End Loop For multiple records, it will be trickier, because where a duplicate appears in your record set depends on how the set it sorted. If the records are unsorted, then duplicates will appear at the bottom of the set. So once the loop duplicates the first record X times, you have to go to the second record in the set, run the loop, then go to the third record, etc. To make this easier, you can keep ommitting the first record. If the records to be duplicated are the only found records, then you can set a global with Status(CurrentFoundCount) and then decrement it after each major loop, stopping when it reaches zero. Set Field [globalcount, Status(CurrentFoundCount)] Unsort Records Go to Record/Request/Page [First] Loop Set Field [globalcopy, copy] Set Field [copy, ""] Loop Duplicate Record/Request Set Field [globalcopy, globalcopy - 1] Exit Loop If [not globalcopy] End Loop Go to Record/Request/Page [First] Omit Record Set Field [globalcount, globalcount - 1] Exit Loop If [not globalcount] End Loop The resulting found set should be only the duplicated records.
December 7, 200421 yr Author Forgive me for asking such a silly question but I am unable to get Set Field [globalcopy, copy] when I select the Set Field option in Scriptmaker. I am able to specify only the one field - copy. Does this script require two fields - both a globalcopy field and a copy field? Thanks again for your help
December 7, 200421 yr globalcopy is the field to specify as the target field. copy is the calculation to specify. globalcopy should be a global number field. You can either create a new global or use an existing one that isn't being used elsewhere in the script.
December 8, 200421 yr As macusers do we have yet another option when the request is to make X dupes: Perform AppleScript [ Calculated AppleScript: "repeat " & GetAsText ( Int(Ln ( test::gDupeRequest ) /Ln ( 2 ))) & " times
December 8, 200421 yr Author I have it working beautifully! Thanks for both of your help. It is much appreciated.
Create an account or sign in to comment