Forum Discussion

MattHardy1's avatar
MattHardy1
Qrew Trainee
20 days ago

Bulk Record Creation (User Defined # of Records)

Can anyone suggest how I can create an unknown number of child records? Sometimes the user might need 10, 50, 200 or any number in that range. I would like the user to have the option to enter this # in a field and click a button to trigger the process. I thought I could use a pipeline loop but I don't see a way to run the loop a number of times based on a field value. 

My goal is to populate the table shown below, with no data, allowing the user to quickly input the data right on this form without adding/opening/editing each individual record. I'm happy to provide more details or take a different approach.

Thanks

5 Replies

Replies have been turned off for this discussion
  • There is more than one way to do this, and the pipeline Ninja Jinja will have fancy methods with loops that count. but they will probably run slowly and be too technical for me, at least.

    Here is a fairly low tech solution, which assumes that it is unlikely that two users will be doing this at the exact same time.

    1. Create a Helper table called Suite Helper with all the possible values for the child records imported into a field called [Counter], so maybe import an excel sheet from 1 to 1,000.

    2. Create a single record table called Suite Count Select with exactly 1 record in it.  It wiull be [Record ID#] = 1 Lock it down so no one, even the admin, can add or delete.
    3. Create a field on that record called [# of Suites] and another for [Record ID# of Building]. I am making the assumption that the ultimate Parent table for the children will be Parent Table is called Buildings.

    4. Create a relationship where 1 Suite Count Select has many Suite Helper with a formula reference field on Suite Helpers with a  formula of 1.  Lookup the [# of Suites] and the [Record ID# of Building].

    5. Create a saved Table to Table Copy to copy records into the Child table from Suite Helper and map the [Record ID#] (lookup) into [Related Building], and set the filter where the [Counter] is less than or equal to [# of Suites].
    6. Make a field on Buildings for [# of Suites]
    7. Now make a Formula URL button on Buildings.

     

    var text SetTargetBuildingAndNumberToCreate =

    URLRoot() & "db/" & [_DBID_SUITE_COUNT_SELECT]

    & "?act=API_EditRecord&rid="

    & "&_fid_6=" & [# of Suites]

    & "&_fid_7=" & [Record ID#]; // ie the record ID # of the Building you are sitting on.

    var text ImportChildren =

    URLRoot() & "db/" & [_DBID_OF_CHILD_TABLE] 

    & "?act=API_RunImport&ID=10";

    var text RefreshPage =  URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

    $SetTargetBuildingAndNumberToCreate 
    & "&rdr=" & URLEncode($ImportChildren)
    & URLEncode("&rdr=" & URLEncode($RefreshPage))

    Another way to do this with a simpler setup would be to have the same helper table for Suite Helper and trigger a Pipeline with a checkbox on the Buildings table to Search that Table and then get rid of the loop that the Pipeline setup will offer and instead use the relatively new "Import to Quickbase Step" 

    Either way a Helper table with records from 1 to 1,000 will give you some help.

    Feel free to post back with questions or if need be I can hop on a fast call with you next week.

     

  • I did something similar to what you're looking for but with start/end dates in a set interval. I'll try to explain what I did! 

     

    I had a parent table, Agreements, and a child table, Rental Amounts. The idea was that the user would enter [Rental Payment Effective Date], [Rental Payment End Date], and the [Payment Frequency] (monthly, yearly, or one time). In the Agreements table I also had a checkbox for [Trigger to Create First Rental Amount Record]. I made a button that the user clicked to mark the trigger checkbox as true. 

     

    I then created two pipelines. The first was On New Event, when an agreement record was added or updated and the [Trigger to Create First Rental Amount] was checked. This created the initial child record and populated the following fields on the child record: [Effective Date], [Due Date] (calculated based on effective date and payment frequency), [End Date], [Amount], [Payment Frequency], and [Related Agreement]. The pipeline then unchecked the trigger checkbox, in the event that the user needed to add additional rental payment records. 

     

    The second pipeline triggered whenever a rental amount record was created and the [Payment Frequency] was not "One Time". I had a "condition" step that checked the [End Date] against a formula field for [Next Due Date]. [Next Due Date] looked at the [Payment Frequency] and used either AdjustMonth or AdjustYear to calculate the next payment due date. If the [Next Due Date] was after the [End Date], then the pipeline stopped. If the [Next Due Date] was before the [End Date], another rental amount record was created, populating [Next Due Date] into the [Due Date] field. With this, it keeps creating child records until that [End Date] is before the [Next Due Date], at which point it stops.

     

    You could probably apply similar logic to what you're trying to do, using numbers instead of dates. You could have the user enter the [Number] of child records to be created, and then have a counter on the child record to calculate the [Next Number] (or whatever you want to call it). You don't have to display the counter, but the pipeline could trigger if [Next Number] is less than or equal to the current [Number], and then stop if [Next Number] is greater than [Number]. 

     

    Sorry, that's a massive explanation and I hope it made sense. If I can provide any more details, please let me know. 

  • Thanks Kelly & Mark! I ended up using parts of each of your solutions.

    I created a helper table called "Blank Records" with 500 empty entries. Then used a pipeline to grab the [# of Suites] from the "Buildings" table and used that to search for "Blank Records" with a RecordID# < [# of Suites]. That returns a list the same size as [# of Suites] to run a loop on. Within that loop I added a bulk upsert row. Finally after the loop completes, I commit the upsert. 

    • MarkShnier__You's avatar
      MarkShnier__You
      Icon for Qrew Legend rankQrew Legend

      OK, great that you got it working. But if you're looking for some real fun and are willing to invest five minutes, try duplicating your pipeline and hack away everything except the trigger and the search step.  

      Then insert a step after the search for import to Quickbase. 

      I think you'll find that find that it runs about 10 times faster. So in a worst case if you had 500 suites, I bet it would take way more than a minute to complete your way with the loop. But I'll bet the Import to Quickbase isn't really sensitive to the size of the number of suites being created and will complete in about five seconds.  

      It also saves you the set up of creating the bulk upsert and then they add row step and then the final Commit. So in future Pipelines you build, it seems simpler to just go directly to the Import to Quickbase directly after the Search.  

      • MattHardy1's avatar
        MattHardy1
        Qrew Trainee

        Oh that's even better and such an easy change. I've never used (or even noticed) that import to quickbase action. Now I'll need to go through all my pipelines to see where I can use this. 

        Thanks!