Automation - Add dynamic amount of records to a table

  • 0
  • 1
  • Question
  • Updated 4 days ago
  • In Progress
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...
Photo of Austin Hayes

Austin Hayes

  • 160 Points 100 badge 2x thumb

Posted 5 days ago

  • 0
  • 1
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,786 Points 50k badge 2x thumb
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.
Photo of Austin Hayes

Austin Hayes

  • 160 Points 100 badge 2x thumb
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.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 52,786 Points 50k badge 2x thumb
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.
Photo of Ⲇanom the ultimate (Dan Diebolt)

Ⲇanom the ultimate (Dan Diebolt), Champion

  • 27,694 Points 20k badge 2x thumb
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,
(Edited)