Picture a simple scenario, your company uses Quick Base to track PTO Requests and manage timecards. When an employee enters a request, you'd like to automatically generate a timecard for each day they'll be out.
Think of another, where you are setting up a new project. Part of the set up is picking a number between 1 and 25 representing the # of Milestones. When that project is set up, you want the milestones to all auto-generate so you can assign the respective dates and descriptions in grid edit rather than adding them all one by one.
From a technical standpoint - that kind of automation is tricky because of the 'unknown'. You don't have any clue what days or how long someone will be out for PTO. You don't know how many milestones you will have for your project until you save it.
What options do you have then?
An alternative to all of the above though, is to combine a little creativity with Quick Base formulas to build out a pseudo-CSV, and combine it with Webhooks to dynamically generate your set of child records.
To explain that a little more, first it helps to break down exactly what a CSV means in this context. Most would think of an excel or txt file, but really a CSV is just a list of values, separated by columns and line breaks. With that in mind, you can easily incorporate both of those into standard Quick Base formulas, utilizing common formula-text fields and if() statements, to generate the pseudo-CSV mentioned above.
Let's say for our milestones example, my new project will need exactly 17 milestones. In my project set up, I have a numeric field for [# of Milestones]. Using If() statements in a formula-text field, you can create something like this:
if( [# of Milestones]>=1,[Related Project] & "," & "Milestone 1" & "\n", "") &
if( [# of Milestones]>=2,[Related Project] & "," & "Milestone 2" & "\n", "") &
if( [# of Milestones]>=3,[Related Project] & "," & "Milestone 3" & "\n", "") &
if( [# of Milestones]>=4,[Related Project] & "," & "Milestone 4" & "\n", "") &
if( [# of Milestones]>=25,[Related Project] & "," & "Milestone 5" & "\n", "") &
The output of which, if I want 17 milestones, will look something like this:
**For this example - 1111 is being used for [Related Project]
Remember that because a CSV is a list of values, separated by commas, make sure when you set it up that you are sure to include & "," & between each of data point. In addition, each 'row' needs to end with "\n" to tell Quick Base that you want to start a new row after that.
So now a simple Quick Base formula dynamically creates a CSV of my 17 milestones. With that in hand, Quick Base natively allows you to create an API_IMPORTFROMCSV webhook that you can pass that example into. Webhooks in this instance allow you to POST your newly created CSV to the Quick Base API. It is important to use API_IMPORTFROMCSV, as this allows you to create/update any number of records, rather than doing single ADDRECORD / EDITRECORD calls. Your setup is such that your formula is added as part of the <![CDATA[ ]]> like below
[My CSV Generation Field goes here]
And voila, a simple Quick Base formula can handle creating your milestones for any number between 1 and 25. This simple but powerful technique can be used in all sorts of circumstances where you don't always know what your child records will look like. Some other examples you might use it for:
The options though are really only bound by what you can put into a formula. The best part is that there is no custom code or additional services needed, and you can easily make updates by just updating your formula.
To see an example of this, head over the the Quandary Quick Base Knowledge Center to test it.
Author: Chayce Duncan (firstname.lastname@example.org)
Date Submitted: 1/3/2019