Forum Discussion

MattS's avatar
MattS
Qrew Member
2 years ago

Add Multiple Child Records at one time to a join table and have the records linked to both parent tables

Is there a way to add multiple child records from a parent table to a join table at one time and have them linked to both parents? 

I want the records created in the join to be linked to both parent tables, but I don't want to have to have individuals edit each individual record created and manually link to the other parent. 

Please note the following:

  1. The number of child records being added would not be static and would vary from entry to entry.
  2. Tags have relationships elsewhere in my build so it is not as simple creating the relationship of Batches have many Tags.

The way I currently have it set up is there are two Parent Tables (Batches and Tags). These two tables are connected by a join table. 

The Tag table is pre-loaded with tags that each have a unique Tag ID, so the tags already exist. The tag IDs are sequential and unique. 

The action starts after a Batch in the Batch Table has been created, however it doesn't trigger immediately after creation. The action would trigger when the Batch record is updated and a certain field is populated, but I'm trying to determine what (if any) field could do this.   

I have two ideas but I cant find any solutions on how to make them work/if this is even possible.

My ideal solution would be to have 2 fields in the batches table [Starting Tag #] and [Ending Tag #]. These 2 fields would trigger an action that would search the records in the Tags Table to find the  [Starting Tag #], [Ending Tag #], and all of the tags between them. The number of tags would be the number of records created in the join table. The records in the join would have lookups to the Related Batch and The Related Tags. 

The only other idea I have is to have a [# of tags] field in the Batch Table and the number entered in this field would create that many records in the join table. However, this would not solve the issue of having to manually attach Related Tags to each record.

Hope this makes sense. It makes sense in my head but is much more difficult to but into writing. 



------------------------------
Matt S
------------------------------

10 Replies

  • It seems to me that this would be pretty straightforward with a Pipeline. He would figure out what your trigger is and that would be a on new event type trigger.

    Then you would search the tags. Where is the tag number is between the starting tag in the ending tag

    then you would have a For Each loop to create the join table records. 

    In theory, it is more efficient to create a bulk upsert right after the trigger step and then add rows  to the bulk upsert and then at the end of the process commit the upsert, but if you're adding say 10 or 20 records, it will be fine be to do the for each loop to create the join table records.



    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------
    • MattS's avatar
      MattS
      Qrew Member

      Thanks Mark. I thought it was something like that, but I've been having trouble with the start and end tag search working properly. I will dig into it more and see if I can get it to work. Glad to know I'm on the right track at least. 



      ------------------------------
      Matt S
      ------------------------------
    • MattS's avatar
      MattS
      Qrew Member

      @MarkShnier I'm trying both methods but the problem I'm having is the search for the tags. I obviously don't have the conditions set properly because the loop just keeps running.  Should I be using an advanced query of some sort? 



      ------------------------------
      Matt S
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend

        Can you post a screen shot if your Search filters?



        ------------------------------
        Mark Shnier (Your Quickbase Coach)
        mark.shnier@gmail.com
        ------------------------------