Skip to main content
Question

Add multiple child records to a parent record with Formula URL button and Javascript

  • August 28, 2019
  • 0 replies
  • 195 views

Hi,

I am creating a PTO (paid time off) tracking application in which a PTO period (which can consist of several days) must also be accounted for by hours of PTO taken per day.

I have a parent table for PTO block (paid time off), consisting of a relationship to the employee, a Start Date, and an End Date. I have a child table for PTO days (individual days within the block), with each record consisting of a relationship to the PTO block, a Date (to capture each individual day), and a number of hours per day of PTO used.

I am looking for help with formulating a URL button on a parent record (on the Add Record form, prior to saving) to accomplish the following:

  • Save the record while avoiding the pop-up "you must save record first" dialog (if this is possible)
  • Create the appropriate number of child records for each day of the duration of the PTO block (End Date - Start Date + 1)
    • Don't even get me started on why "End Date - Start Date + 1" isn't a valid formula to Quickbase. Dates are numbers too. MS Excel figured that out a long time ago.
  • Pre-populate each child record with a date, representing each day within the block of PTO time


There is an "Add New PTO" button on the Employee Details form, which brings up a new window to enter the Start Date and End Date.

I'd like to also have the individual child record PTO days available on this new window in a Grid Edit embedded table so that it is easy for the supervisor to enter the number of hours of PTO associated with each day of the PTO block (it's not always the same number).

Is this possible? And if so, can someone point me in the right direction to figure out how to go about this?

Thanks!



------------------------------
Jason Bowen
------------------------------
This topic has been closed for replies.

MarkShnierYou
Forum|alt.badge.img+24
For the Save record first issue, I'm not quite sure where this is popping up for you, but in general, on any Parent table you should got to Advanced Properties and set the checkbox called.
Save parent record automatically when a child record is created

As for creating X number of child daily records on the PTO entry, this can be done with an Automation. Lets assume that you limit a PTO request to 2 weeks so max 10 business days 

I suggest that when a PTO is added or edited or deleted, you trigger an Automation with the following steps.

1. Delete all the daily  children for that PTO.

2. Create say 10 days of children for each of the possible 10 Business days starting on the 1st day.  That will take 10 steps in the Automation and you will need to create 10 formula date fields to use.

3. Then the last step will be to delete all children which are not within the date range of the PTO.  You can lookup the date range and create a flag field to indicate of the day is within the PTO Date range.

------------------------------
Mark Shnier (YQC)
markshnier2@gmail.com
------------------------------