June 27, 200520 yr I am trying to figure out the best way to duplicate complex records... these have several portals in which related records are created, and when I duplicate, I want all that duplicated also. I have some ideas, but right now they all look pretty complicated. Anybody been there done that? (What I'm really after here is a way to copy a record when user selects an "edit" button, then present either the original or the copy to the user for editing... end result, I hope, is a way to switch back to the original version if necessary or just see what it was... I have an audit log field that works OK but doesn't capture the child data)
June 28, 200520 yr Author Yes it helps some... one of the posters in that thread mentioned a disconnected TOs approach. I post a question about that. I don't see there what he means, but it sounds like a more bullet proof route than a looping script.
June 28, 200520 yr If you look at the Relationships, you will notice that Current Invoice is a TO based on Invoice, but not linked to anything. This is what he means by a disconnected TO.
June 29, 200520 yr Author There appears to be a missing attachment ... he refers to a FMP7 attachment but I don't see it anywhere. I'm new to this forum though... maybe I am not looking in the right place? All I can see is a link to a zip file, which is a couple of FP3 files and some scripting.
June 29, 200520 yr Hi JT, There isn't a post on this page with an "Attachment" in it. Are you referring to the link in "See if [color:"blue"] this thread helps you." attached to the word [color:"red"] this in your first post. HTH Lee
June 29, 200520 yr Yes, Lee, the linked thread is what we have been discussing. Glad you found it, aadeanb!
June 29, 200520 yr Author Well, found it, studied it a while. I'm having trouble figuring out all the logic of the script. For whatever reason, in my own file, what I get is a new record with *only* the child data copied. Haven't figured out why this happens. But it looks like his sample does the same thing. However, since I don't really grasp the logic, I don't know how to amend it & get what I want... a copy of the current record AND it's child data. Maybe after I take a break and look at it in a day or two it will click.... or maybe I'll do the much less elegant way that I think I can make work (lots of globals and setfields).
June 29, 200520 yr Well, if it helps, here's how I do it. You only need one additional relationship, from Parent::global to Child::ParentID. I denote this as Child|global below. If [isEmpty(Get(ScriptParameter))] Allow User Abort [Off] Set Error Capture [On] Set Field [Parent::global; Parent::serial] Duplicate Record/Request Perform Script ["This Script"; Parameter: Parent::serial] Else Commit Records/Requests [skip data entry validation; No dialog] If [not IsEmpty(Child|global::serial)] Go to Related Record [show only related records; From table: "Child|global"; Using layout: "Child" (Child)] Go to Record/Request/Page [Last] Loop Duplicate Record/Request Set Field [Child::ParentID; Get(ScriptParameter)] Omit Record Omit Record Exit Loop If [not Get(FoundCount)] End Loop Go to Layout ["Parent" (Parent)] End If Commit Records/Requests [skip data entry validation; No dialog] Halt Script End If
June 29, 200520 yr Author Thanks! Let me just try to get the logic a bit here before I try this. In your solution, there is no disconnected TO... the parent table is related to match field in the child one by way of a global? Is this a straight equijoin? Parent::Serial is just a field in the parent table that increments serially?
June 29, 200520 yr Parent is related to Child in two ways: one being the normal Parent::Serial to Child::parentSerial (change to whatever field names your portal uses), the other from a global in Parent to Child::parentSerial. The second is to make it easy to go to the original record's children (if there are any) once you are on the duplicated record. The script parameter is then used to overwrite the duplicated children records with the duplicated Parent::Serial. I do not use disconnected TOs. I prefer to add a relationship than a TO that may appear to have no use in the relationships graph.
Create an account or sign in to comment