January 27, 201016 yr 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 January 27, 201016 yr by Guest
January 27, 201016 yr 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 January 27, 201016 yr by Guest
January 27, 201016 yr 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?
January 27, 201016 yr No 21 lines would do, and this is without any tightning up at all. See the attachment to my previous now modified post. --sd
January 27, 201016 yr 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".
January 27, 201016 yr 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?
January 27, 201016 yr 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
January 28, 201016 yr 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.
January 28, 201016 yr 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
January 28, 201016 yr 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
January 28, 201016 yr 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