Skip to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Duplicating a record and its children

Featured Replies

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

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

  • Author

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?

  • Author

I don't want to do a 100+ line script! :tears:

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

--sd

  • Author

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".

  • Author

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?

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

  • Author

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.

  • Author

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

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

  • Author

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

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.