Auto add child records

  • 0
  • 2
  • Question
  • Updated 2 years ago
  • Answered
I have 4 tables -
-Projects
-Tasks
-Project Templates
-Tasks Templates

there a 3 Parent-Child relationships
1) Projects (P) - Tasks (C) 
2) Project Templates (P) - Tasks Templates (C)
3) Project Templates (P) - Projects (C)

I would use the Template tables to create -- well -- templates -- Project Template A --- will have Template tasks associated (child details)

My goal is to create a new Project record and while in the "add record" mode --- I will select the Related Project template (parent) ---

At this point I would like to have a "magic formula button" -- titled "Auto Add Tasks" -- that when clicked:

1) It saves the Project record

2) It Imports/copies the Task Template records that are related to the Related Project Template - into the Tasks Table and relates the new tasks to the new Project record

3) Then redirects me back to the recently created Project record n Edit Mode -

This is a doozie -- I'm sure Mark has answered this before....Thanks for any and all help. 
Photo of rocketc

rocketc

  • 494 Points 250 badge 2x thumb

Posted 2 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 50,850 Points 50k badge 2x thumb
Can I ask why you are not OK with the traditional solution.  User saves the record, and sees a single button controlled by fomulas or form rules to show the correct import button for the selected Template. User pushes the button.

Have you got that method working yet? 
(Edited)
Photo of rocketc

rocketc

  • 494 Points 250 badge 2x thumb
Mark,

Where I get lost on using the traditional "copyMasterDetail" method -- Is the fact that I only know how to use this method when Copying details from a Master record --- within the same Master table....so if I only had 2 tables within my application Project Templates & Tasks Templates -- I know how to use the traditional methods...

But I want to leverage the Project Templates & Tasks Templates tables to populate the other two tables...so not sure how to leverage the copyMasterDetails when copying from different tables....

the redirects are not as important....
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 50,850 Points 50k badge 2x thumb
OK, I now understand that your task templates is not on the same table as your tasks.  I did not read your post carefully enough.

So my next question is are you "married" (or at least going steady - I'm sure that kids have new words for that now)  to that concept to have the task template records not be on the same table as the tasks.  Typically, you would have just 2 tables and not 4.  Is it too late to go to that concept or did you have other reason to duplicate the tables.

If you do want to maintain that concept, then yes there is a way to make a button to do that, but it does get way more complicated and would take my as long to explain how to do it than to actually do it.  It's probably an hours work  for me to set that up for you. 
Photo of rocketc

rocketc

  • 494 Points 250 badge 2x thumb
Definitely not married not really in love just very fond of the 4 tables. Let me try going with just two tables....still pretty......If I run into any issues or questions I may seek your advice...Thanks for helping me remove the beer goggles. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 50,850 Points 50k badge 2x thumb
OK great. KISS is usually the best plan.  Then what you do is to make a set of import buttons using the wizard and then make a form rule to show the correct button for the correct selected template choice - that template may just be a multiple choice field.
Photo of Matthew Neil

Matthew Neil

  • 31,438 Points 20k badge 2x thumb
4 tables is the way to go.  What happens when you add a new project type, and have a new template list, another button, another form rule, another template list to hide from reports...

If you do it they way you planned (4 tables) then you get great expansion and flexibility.

If you go 2 tables, then you have to filter out those items from all your reports that you build in the 2 tables to avoid your data from getting jumbled.

I do the 4 table set up about once a week in different apps.

One Con: You have to make a .js code page.