Forum Discussion

AustinHayes's avatar
AustinHayes
Qrew Cadet
7 years ago

Automation - Add dynamic amount of records to a table

I'm looking to add records to a table via an automation based on a variable numeric field in the trigger table. So if the field is 1 I add one record to a table, if 2 then 2 and so on...
  • Low tech solution if you have a limited number of choices for the # of records to be added, say between 1 and 10 is to have 10 Automations and fire them based on checking that number.

    It is also possible to write a looping Automation which will increment a counter and then trigger itself to run again as long as the counter is still less that the number to be added.

    You can do up to 100 loops before Quick base will assume that you may have created and endless loop and stop the process.
    • AustinHayes's avatar
      AustinHayes
      Qrew Cadet
      I think the looping is more applicable to my desired function. Let's say I initially fire the automation to be looped based on marking a checkbox; Can I then keep firing the automation based on the incremented field changing as a result of the automation? So the trigger is any of the following fields change: checkbox & counter.

      If so, mine does not appear to increment correctly. I modify the loop numeric field in my automation. I have source set to both type and copy values. Then I grabbed the loop field and said + 1. What do I need to change to get my automation to increment a loop that continually triggers itself.
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      You can�t do calculations in the automation set up.

      Make a feld on your trigger record which calculates a counter plus 1 and then have the Automation map that field into the counter.
    • AustinHayes's avatar
      AustinHayes
      Qrew Cadet
      I have implemented this solution and it is working to my satisfaction. Thanks for the input.
  • Don't use Automations - just use a simple native formula (with some embedded JavaScirpt)! If you use 100 looping Automations QuickBase will run low on inventory and everyone will be effected.

    Without loss of generality, I am going to assume you want to create N child records associated with a parent record you are viewing.


    Here is the demo:



    Create N Child Records ~ View Parent Record 
    https://haversineconsulting.quickbase.com/db/bn8aam6y8?a=dr&rid=1

    Pastie Database
    https://haversineconsulting.quickbase.com/db/bgcwm2m4g?a=td&rid=698

    Notes:

    (1) Feel free to create your own parent record and add your child records to it by viewing the parent record and clicking the button.

    (2) You can customize the formula further by editing some of the hardcoded ids and apptoken

    (3) No code pages was used in the creation of this demo.

    (4) This is a great way to initialize child records representing a number of fixed assets such as seats in a class,
    • AustinHayes's avatar
      AustinHayes
      Qrew Cadet
      I will look into this as an alternative to the loop. I'm not concerned about having a single looping automation in my app.