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

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

Recommended Posts

Posted (edited)

Hi,

Is there an efficient way to duplicate a record and its children? (Yes, I need to duplicate some of the children)

The algorithm I'm thinking of is :

duplicate the parent record

Get its primary key

Go to original record

Traverse all children // TEDIOUS PART!!

Duplicate each child

change foreign key to new parent

The long part is to traverse allll children tables, when there are like few levels of them, it's so long to script.

I just want to know if there is a generic way to do it?

Edited by Guest
Posted (edited)

Well your choice of platform prevent you from doing this:

http://tokerud.typepad.com/filemaker/2006/06/new_record_with.html

Is it?

--sd

main.zip

Edited by Guest
Posted

Hmmm... I don't think that changing all the desktop to Mac is a wise choice. :

Do you know if there is a vbscript equivalent?

Posted

No 21 lines would do, and this is without any tightning up at all. See the attachment to my previous now modified post.

--sd

Posted

Hmmm... interesting.

But how about children of children table? Do you have to create a layout and a portal for each one of the table occurrences?

In my case, the report has at least 20 children tables going through 4 levels...

I guess tweaking around using portals and a recursive script I can get to something. Although I see a problem with the GTRR since it's not "customizable".

Posted

I like the "get (scriptparameter)" in the fk_main!

But can there be a problem using this method? Like creating a child record from another script?

Posted

Yes there can obviously, but you can then make the autoenter conditionally via Case(GetScriptName( = "someting"

http://fmhelp.filemaker.com/fmphelp_10/en/html/func_ref2.32.63.html

--sd

Posted

After searching here and there, I think I will have to create a megascript since the record type I want to duplicate has 31 dependent children under 4 levels..

If there was a generic GTRR (sort of GTRR by name) this would simplify my script greatly.

Posted

Wouldn't it be nice if this algorithm could translate to FM :


script DuplicateRecordTree (parentID as string)

begin

   Duplicate Record

   pk = newRecord.pk

   

   if (parentID <> "")

      Set newRecord.fk = parentID

   end if

   

   omit record

   

   if (currentTable.hasChildTables)

      foreach (childT in currentTable.childTables)

         if (childT.records.related.count > 0)

            foreach (r in childT.records.related)

               Goto Related Record®

               DuplicateRecordTree (pk)

            next

         end if

      next

   end if   

end script

Posted

If there was a generic GTRR (sort of GTRR by name) this would simplify my script greatly.

You can borrow an idea or two from this approach:

http://web.mac.com/zueiv/iWeb/FileMaker/Script%20Killing%20Techniques/AFA363C6-2D85-4C6D-82E2-273F3722A69E.html

--sd

Posted

Hey thanks! That's pretty interesting. Thanks also for the web didn't know this one.

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