Forum Discussion

MichaelTamoush's avatar
MichaelTamoush
Qrew Captain
5 years ago

Add Record then Add Child to Record with Button Push

If I want to use a button push to add a record, and then add a child to the record, is my only option to add record, then trigger an automation or pipeline as the second part of that button push?

I can't do it from the button push because I won't have the new record ID yet, correct?

------------------------------
Mike Tamoush
------------------------------
  • Mike,

    What data is going into the Child?  If you want to add some sort of "standard" set of data then what you said will work.  

    You can also embed a Grid Editable report into the Parent record.  You can add data there which Quickbase will magically associate with the New Parent on the Save.

    ------------------------------
    Don Larson
    Paasporter
    Westlake OH
    ------------------------------
    • MichaelTamoush's avatar
      MichaelTamoush
      Qrew Captain
      The child data will be a manual input. The add child is a GenAddRecordForm. Once they Save the record it could run the next URL in the utton push, but I don't think in that code I can get the Record ID from what they just created.

      I am currently using a pipeline for the 2nd step, which works, just wondering if it could be done from the button push.

      ------------------------------
      Mike Tamoush
      ------------------------------
      • RubyKapil2's avatar
        RubyKapil2
        Qrew Captain
        Would Copy Master Detail feature work. It lets you have a button that will Copy the existing Record and it's Children?

        ------------------------------
        Ruby Kapil
        rubykapil@wi-finity.com
        Wi-Finity, Inc
        ------------------------------
  • Hi Mike, I saw your similar question on my YouTube channel, thanks for subscribing!

    You can use a code page with a button.

    It's not quite clear what your workflow is, but this combo will create a new parent record, then open new child record with the parent pre-populated with a single button click.

    The button could be located on a form (using a formula or plain URL field) or on a dashboard.

    Formula URL field (the button):
    URLRoot() & "db/" & AppID() & "?a=dbpage&pageid=10" //replace the URLRoot & AppID if not using a formula

    Code Page:
    <html>
       <head>
         <script src="https://code.jquery.com/jquery-3.5.0.js"></script>
         <script>
            $.get('https://mycompany.quickbase.com/db/parent_dbid?a=API_addrecord',function(data,success) {
               var myrid = data.getElementsByTagName('rid')[0].innerHTML;
               location.replace('https://mycompany.quickbase.com/db/child_dbid?a=API_GenAddRecordForm&_fid_12=' + myrid);
            });
         </script>
       </head>
    </html>

    Let me know if this works for you đź‘Ť


    ------------------------------
    Sharon Faust (QuickBaseJunkie.com)
    Founder, Quick Base Junkie
    https://quickbasejunkie.com
    ------------------------------
    • GabrielFigueroa's avatar
      GabrielFigueroa
      Qrew Member
      Hello Sharon,

       I am getting the below message.
      The only difference was that instead of going to a Child record I wanted to stay (go to) the parent record just added.



      ------------------------------
      Gabe Figueroa
      Contractor
      Miami FL
      214-490-1719
      ------------------------------
      • QuickBaseJunkie's avatar
        QuickBaseJunkie
        Qrew Commander
        @Gabe Figueroa Are you using a different key field from the record ID?

        Try running a sample url through your browser, such as (https://mycompany.quickbase.com/db/parent_dbid?a=API_addrecord​)

        You'll see something like this:
        The "get inner HTML" for the 'rid' is referring to the <rid>X</rid>, so if you don't see that it could be the issue.
        You may also need to add an apptoken if your app requires them.


        ------------------------------
        Sharon Faust (QuickBaseJunkie.com)
        Founder, Quick Base Junkie
        https://quickbasejunkie.com
        ------------------------------