Forum Discussion

StephanieStepha's avatar
StephanieStepha
Qrew Trainee
10 years ago

Automatically create child record when parent record saved

Is it possible to, when my parent record is saved, have a formula that will (if a specific field has been updated), automatically create a child record on my related child table, populated it with the data from that field and then save it (without the user having to hit Save manually)

Thank you in advance!!

18 Replies

  • That's not possible, but it's certainly possible to have a button to push to create a child record, and the button could be set to only appear if certain conditions are met.  You would use the API called API_AddRecord.  Post back if you need help with that.
  • Is there a way to just auto save that new child record so that you don't have to navigate from the parent record? My child record is only pulling info from the parent, no new info is being added.
  • I am following the article link above and it is working well except for the following 2 items.
    1.  I had to disable my app tokens to get this to work.  What code would I need to add to get the app token to work again?
    2.  I have to save the project before clicking on the button for it to work.  What do I need to add to the button formula to save the project first and then create the child records?
  • To get the app tokens to work, you need to add a line to the URL

    & "&apptoken= xxxxxxxxx"

    With the method described in that article you will need to save the record before importing the children.  How many children are you adding?
  • Thanks for the info on the app token.

    The number of children varies depending on the selection, but a minimum of 5.  The current button I am working on adds 5 records.  Is there something I can add to the URL formula to save the parent record first and then create the children?

    Here is my current formula:

    var text SetFocus = URLRoot()&"db/"&[_DBID_FOCUS_TASKS]

    & "?act=API_EditRecord&rid=1"

    & "&_fid_6=" &[Record ID#];

    var text RunImport= URLRoot()& "db/"&[_DBID_TREATMENT_BATCHES]& "?a=API_RunImport&ID=10";
    var text RefreshRecord= URLRoot()&"db/"&Dbid()&"?a=dr&rid="& ToText([Record ID#]);

    $SetFocus
    &"&rdr="& URLEncode($RunImport)
    &URLEncode("&rdr="& URLEncode($RefreshRecord))
  • I do not believe that there is a way to do that without using script.  The issue is that to create the children, they need to know the Record ID# of the parent.  But the Record ID# of the Parent is not known until it is saved.
  • Darn.  I was hoping there was something easy I could add to the URL formula.

    Seems like a major flaw of the whole process outlined in the article.
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      Maybe you should start at the beginning with your goal.

      If all you want to do is to start with say a half a dozen templated projects which each have a different set of tasks, click 1 button and get a copy of the project made along with its set of tasks, then all you want to do is to use the native functionality to Copy Master Detail.

      That button is on App management and that will walk you though the setup in a few clicks.

      Is that your real goal?

       
  • I don't understand.  Can the script be added to the formula-url?  What script would need to be added?
  • By "script", I mean that you will need to engage with a developer to get this working for you and scrap what you have done so far.  If you contact me via the information in my website QuickBaseCoach.com, I can recommend a developer to do this for you.