Forum Discussion

ChrisBaker2's avatar
ChrisBaker2
Qrew Member
2 years ago

Best practice when trying to create parent and child records with a single csv import.

More context here Discussions

I was able to use a pipeline to create child records after manually adding fields to parent but the requirements have changed and I now need to create both the parent and child from one csv file. 

My current thought process is that I need two separate csv files and somehow get the record id after the first step in the pipeline and add that value into the other csv column with the recordid header all within pipelines but I am not sure how to approach this.



------------------------------
Chris Baker
------------------------------

2 Replies

  • I was thinking about your original discussion but never chimed in there.  

    I think you could have a workflow like this.  

    Have a table where you upload the children as a file attachment.  

    Have a table where you upload the parent record as a file attachment with just the one record in it. 

    Always be very sure you upload the csv for for children first.

    Figure a pipeline when a parent CSV file is loaded and create the parent record.  

    Search for the trial table file attachments where the record has not been flagged as process. Limit  the search at the first record found.

    UpLoad the children but of course at this point they will be orphans not linked to a parent.  

    next create a bulk upsert in to children with the columns being Record ID# and the related parent.

    Then search for all orphans and in a for each loop populate record ID and related parent, populated as the record ID# form the trigger step A.

    The pipeline to relay the orphans to the parent is going to run unfortunately pretty slow. Probably about five records per second. I don't know how big your file will be of children but if it was 1000 children about three minutes to run. If that's too slow for your user experience then there are some additional pipeline steps I can describe which update the children in about one second. 



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

      Okay thanks I will look into this. The uploads only occur a few times a month so I think the wait would not be an issue. 



      ------------------------------
      Chris Baker
      ------------------------------