Jump to content
Salesforce and other SMB Solutions are coming soon. ×

Duplicate records in a script loop


FredP

Recommended Posts

I have a script where I am trying to clone some records so that a copy of them are created and linked to another project by duplicating the record, and changing the parent_projectID for the new record. But i hit a snag.

 

I do a find, that lets say returns 3 records.

 

I planned to do a script that was as easy as

Goto first record

Loop

Duplicate Record

Set Field ParentRecordID# to $newRecordId

Goto Next Record Exit on last

end loop

 

But this causes a problem. With 3 records found, when I duplicate a record, the new duplicate becomes record #4 in the found set, thus when it changes, the record id and tries to "goto next record, exit on last" it exits, because the new record, #4, is the last in the found set.

 

Is there any way around this? I would like to retain the order So that I can loop through the 3.

 

Help!

Fred

Link to comment
Share on other sites

I found the solution in another post:

Anyone who is interested, the loop script looks like this.

Loop
Exit Loop if [get(foundcount)=0]
Duplicate Record/Request
Set Field [template_items::kf_template_id; ""] -- (this clears the
template_id so that the original template does not have the new
duplicated records associated with it)
Set Field [template_items::kf_trip_id; $$trip_id]
Omit Record
Go to Record/Request/Page [First]
Omit Record
End Loop

 

Original thread http://filemakertoday.com/com/showthread.php?t=11336

 

That did the trick for me, thank you all!!!!

 

Fred

Link to comment
Share on other sites

I think you need 'Go to Record/Request/Page [First]' as an additional first step before the loop starts. If the initial record that the loop encounters happens not to be the first record of the found set then the first record won't get duplicated because it gets omitted at the final step of the initial loop pass.

Link to comment
Share on other sites

Yes, Sorry, i tleft that out, but my script did indeed include that.

 

Thanks, that will help anyone else who references this thread.

 

Have a good day!

Fred

Link to comment
Share on other sites



×
×
  • Create New...

Important Information

Terms of Use