Forum Discussion

QuickBase9's avatar
QuickBase9
Qrew Cadet
5 years ago

Copy Child Records from User Selected Parent

There used to be a way to create a Copy Master/Child button where you could let the user browse the parent records and choose the parent to copy the specific children from. Does anyone know if this is still possible? From what I remember it may have been that outside QB wizard that was then replaced with the App level one, but I'm hoping this is still possible without a crazy workaround.

thanks!

------------------------------
Leanne Snoeck
------------------------------

7 Replies

    • QuickBase9's avatar
      QuickBase9
      Qrew Cadet
      Thanks for the location Sharon! This is actually an action that cannot be completed by the provided wizard alone. With Mark's help I was able to get this completed, and will include the specific instructions here. I've also run into another issue with this wizard, that perhaps someone can provide the code/solution to fix.

      Instructions:
      1. Use the wizard to create a button that copies the parent and specific children you would like. Use a single record in the parent table (doesn't matter which one).
      2. Create a relationship between the parent and itself. Then put the Related Parent drop down on your regular parent form. Your users will use this field to select which parent they would like to copy the related child records from.
      3. Edit the code in the button that the wizard created. Where it says source=, that is the number of the record you chose in the wizard. To make this dynamic, change that number to your Related Parent field. Here is what it will look like:
      "javascript:void(copyMasterDetailButtonHandler('&relfids=35\n&sourceRID=" & [Related Parent] & "\n&destrid=" & [Record ID#] & "',...

      It seems that when going through the wizard the Copy Detail records (in the children of children) does not follow the field rules that specify "Do not copy this field when creating a copy of the task" - I've set up automations to clear out some fields, but I'm in real bind with a logged text field. It cannot contain the data from the copied task and I'm not sure how to force that since those logs are not editable. I'm hoping there is a snippet of code I can include in this button to only copy over some fields, or specifically remove this field from being copied. Or another action that can remove this text on newly created records. Anyone know?!?!

      ------------------------------
      Leanne Snoeck
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Qrew Champion
        Copy Master Detail is specifically documented to copy all fields.  So that is expected behaviour and not a bug.

        I have had that same problem with logged fields, typically used to log approvals.  I created a button to push which triggers off the say Project name beginning with Copy of.  It uses an API to disable the logging attribute of the field property, then blanks out the fields and then turns logging back on.

        // turn off logging on two fields
        var text URLONE = URLRoot() & "db/" & Dbid()
        & "?act=API_SetFieldProperties&fid=508&append_only=0";

        var text URLTWO = URLRoot() & "db/" & Dbid()
        & "?act=API_SetFieldProperties&fid=1163&append_only=0";

        //blank out a bunch of fields including the two logged fields
        var text URLTHREE = URLRoot() & "db/" & Dbid()
        & "?act=API_EditRecord&rid=" &ToText( [Record ID#])
        & "&_fid_335=&_fid_668=&_fid_207=&_fid_47=&_fid_272=&_fid_621=&_fid_1163=&_fid_508=" & URLEncode([Project Name] & " " & [Job Quote #])
        & "&_fid_1233=&_fid_1234=&_fid_1235=&_fid_1236=&_fid_1237=&_fid_1238=&_fid_1239="; // clearing all the Freight terms fields

        // turn logging back on for two fields
        var text URLFOUR = URLRoot() & "db/" & Dbid()
        & "?act=API_SetFieldProperties&fid=508&append_only=1&fid=1163&append_only=1";

        var text URLFIVE = URLRoot() & "db/" & Dbid()
        & "?act=API_SetFieldProperties&fid=1163&append_only=1";

        // redisplay the record
        var text URLSIX = URLRoot() & "db/" & Dbid() & "?act=dr&rid=" & [Record ID#];

        // now string hem all together in one button push!
        var text FullURL =
        $URLONE
        & "&rdr=" & URLEncode($URLTWO)
        & URLEncode("&rdr=" & URLEncode($URLTHREE))
        & URLEncode(URLEncode("&rdr=" & URLEncode($URLFOUR)))
        & URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFIVE))))
        & URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSIX)))));

        //Clear Job Notes and Status fields
        // only allow field to be cleared if the record has not been modified - ie its a fresh copy
        If([Date Created]=[Date Modified] and Begins([Project Name],"Copy of"),$FullURL)


        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------
  • Np
    the Copy Master Detail can be initialed either by API or by using the Wizard.  In either case the source and destination end up in the code.  So it's really just a matter of turning that code into a formula to insert the source Parent which has the correct children.

    Typically you would make a relationship to allow the user to  select the source Parent which has the correct children, save and then push the button.


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