Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

duplicate a record and all the "child" data also?


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

Recommended Posts

Posted

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)

Posted

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.

Posted

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.

Posted

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.

Posted

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 cool.gif

Posted

Yes, Lee, the linked thread is what we have been discussing.

Glad you found it, aadeanb! smile.gif

Posted

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

Posted

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

Posted

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?

Posted

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.

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