Skip to main content
Question

How do I create multiple child records by specifying a date range?

  • June 14, 2017
  • 0 replies
  • 134 views

So I have two tables. One for Employees and the other for Vacation Time. How do I create multiple entries on the Vacation Time table at the same time, by selecting a start date and an end date? 

The goal is to have a calendar report showing the name of the employee on each day of the calendar where the date range applies. I don't want to enter the record day by day, one by one. 
Any help would be greatly appreciated! 
This topic has been closed for replies.

  • Quickbase Alumni
  • June 15, 2017
I had this exact same need and had to hire a consultant to create a script. It is 200 lines of code. It works great, but at a high cost relative to a non-code solution. I would love a non-code solution. I don't know how it can be done, though. I would be interested in possible suggestions too. One thing that greatly facilitates my script is a Calendar table that has one record for every business date. The script can pull a subset of those records between the start and end dates to drive the looping.

  • Quickbase Alumni
  • June 15, 2017
How many days is the average date range?

What if you clicked a button x number of times?  So if you had 5 days request, then you'd just click 5 times...

If that sounds like a cheap, but doable solution let me know and I can describe it more.

  • Quickbase Alumni
  • June 16, 2017
Pedro, 

You will want to use the API_AddRecord function in a formula URL to get the new records added / click.


https://<em>target_domain</em>/db/<em>target_dbid</em>?a=API_AddRecord&apptoken=<em>app_token<br></em>&_fid_6="&URLEncode([Record ID#) &"
&_fid_8="&URLEncode([Next Day Off])

For simplicity sake, I'm going to assume you just have 2 tables. 
Parent Table: Employee Requests
Child Table: Days Off

You make a request with that has a [Start Date], and an [End Date].

On the [_Days_Off] table you will have a [Date] field and also relate it to the [_Employee_Requests]

In the relationship make a summary field that summarizes the maximum [Date] of the Day Off.

You will then need to use that [Max Day Off Date] and add one day to it.

Make a formula date field called [Next Day Off], and the equation would be.

[Max Day Off Date]+Days(1)

But if [Max Day Off Date] is blank (i.e. its your first record to be made) you need to account for that.

If(IsNull([Max Day Off Date]), [Start Date], [Max Day Off Date]+Days(1))

Now that you have the set up together, you can work on the formula-url.
Just mapping the Record ID# to the [Related Request] and the Next Day Off to the [Date] field.

You will need a refresh between each click, as to get the most updated max date.  So it might look something like this.

var text URL= https://<em>target_domain</em>/db/<em>target_dbid</em>?a=API_AddRecord&amp;apptoken=<em>app_token</em><br>&_fid_6="&URLEncode([Record ID#)<br>&_fid_6="&URLEncode([Record ID#) &"
&_fid_8="&URLEncode([Next Day Off])<br> ;
"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"

I hope that helps.  Its not my favorite, but if you really can't use script, and need a shortcut to creating multiple records.  This will do it with minimal set up time.

  • Author
  • Quickbase Alumni
  • June 16, 2017
Thank you Matthew!!!!