create multiple child records on saving a parent record

  • 0
  • 1
  • Question
  • Updated 12 months ago
  • Answered
Hi,

I want to create multiple records in child table on saving a record in parent table.
I am trying to achieve these 2 things:
1. The number of records to be created in the child table are based on a field in a parent table.
2. I want to create these records automatically on saving the parent record. I do not wish to create a separate button/link on the form. Is there a way to embed javascript directly on the form without having to display a button?

Any help is appreciated. 
Thank you in advance. 
Photo of Angel

Angel

  • 724 Points 500 badge 2x thumb
  • confused using Javascript

Posted 2 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 53,570 Points 50k badge 2x thumb
If you do not find a better solution and don't have anyone to write javascript for you, then there is an add on product from Juiced called Triggers which can be used.  It's at the bottom of the page.
http://www.juicedtech.com/add-ons


I also know how to do this with a Webhook, but not for the aspect of a variable number of records to be created.  I had to do that myself recently, and while my solution worked, it was not very elegant.

What is the range of the number of child records which might need to be created.
(Edited)
Photo of Angel

Angel

  • 724 Points 500 badge 2x thumb
If I do decide to write the Javascript as a Code Page on my own, how do I embed it in the form?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 53,570 Points 50k badge 2x thumb
We will need to have someone else chime into that thread to answer that question, but I suspect that you answer is here.
https://community.quickbase.com/quickbase/topics/how-do-i-setup-the-image-onload-technique-iol
Photo of Angel

Angel

  • 724 Points 500 badge 2x thumb
I have never used the Image Onload technique myself, but based on my understanding it s used when we want to invoke a js on form load. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 53,570 Points 50k badge 2x thumb
Indeed.  Sounds like what you are wanting to do.
Photo of Angel

Angel

  • 724 Points 500 badge 2x thumb
Thank you. 
Photo of Angel

Angel

  • 724 Points 500 badge 2x thumb
In the meantime, if there is anyone out there to implement this in a simpler fashion please dont hesitate to reach out. Thanks 
Photo of Matthew Neil

Matthew Neil

  • 31,478 Points 20k badge 2x thumb
Fundamentally speaking this wont work with one click.  Reason being, you need to pass the parent record ID# to your code page, so the script knows which parent to tie the children together.

You'll have to save, and then one more click to run the .js page to make the child records.

Just the nature of the beast.
Photo of Angel

Angel

  • 724 Points 500 badge 2x thumb
Thank you for your input. Trying a workaround to achieve this.
Photo of Micaiah

Micaiah

  • 22 Points
You can easily create a formula lookup field which corresponds to the record ID # of the parent record. This would allow it to automatically look it up for you.