Forum Discussion

HarrisonSmith's avatar
HarrisonSmith
Qrew Trainee
5 years ago

Create Duplicate Record from Child Subtable

I have a subtable of child records on a parent form. I want to create a button that can be clicked from the subtable. When it's clicked, I want it to add a new child record, & copy over all of the values in each field of the child record the button was clicked on (there's actually one field I don't want to copy; I'm not sure if there's a way to actually "duplicate" a record, but if there is, I can't quite do that because of this 1 field I don't want copied, so I think adding a new record & populating the fields from the clicked on child record would be best), and then redirect back to the parent record the user was on (where the duplicate record will now display). So, this button would appear on every child record in the subtable. I can't just create a button that populates with hardcoded values, as the values will change depending on which record the button is clicked from. Any suggestions?

------------------------------
Harrison Smith
------------------------------
  • There is an app in the exchange called API Formula for Dummies.  I suggest that you download that app and then post back with questions.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • HarrisonSmith's avatar
      HarrisonSmith
      Qrew Trainee
      Downloaded, and the formulas you have there make sense. The part I'm stuck on is how to populate the fields dynamically based on which child record the button is clicked from. In your examples, the field values are hard-coded ("PO Line Approved"}. Or maybe I'm just missing something obvious.  



      ------------------------------
      Harrison Smith
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        OK, here is another example

        var text ClockPunch = URLRoot() & "db/" & [_DBID_TIME_PUNCH] & "?act=API_ADDRecord"
        & "&apptoken=xxxxxxxxxxxx"
        & "&_fid_17=" & URLEncode([Field 1])
        & "&_fid_81=" & URLEncode([Field 2]);

        var text ReturnToEmployeeClockForm= URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];

        $ClockPunch
        & "&rdr=" & URLEncode($ReturnToEmployeeClockForm)

        //  in this example i am putting the values from Field 1 into field ID 17.
        // if you have Application Tokens enabled, the you will also need to include that line
        // if the data you are putting into any of the fields might have spaces or special characters, then you should URLEncode them or it might fail.  You are creating a URL click which needs to travel though the mysteries of the internet and the internet does not like spaces or special characters in URLs.

        if your formula does not work, please post an editable  copy and paste the code and not a screen shot of the code.

        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------