Creating a child record from a button on the parent form and automatically return back to the parent form after the child has been saved.

  • 0
  • 1
  • Question
  • Updated 7 months ago
  • In Progress
Creating a child record from a button on the parent form and automatically returning back to the parent form after the child record has been saved.

User is on parent form and adds a record to the child form through a button. Is there a way to automatically return back to the parent form after the child form has been saved? If not, it there a way to indicate on the button that a child record has been created for the parent record by changing the color of the button? This is my existing formula  URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=API_GenAddRecordForm&_fid_17=" & URLEncode ([Record ID#])& "&z=" & Rurl()



Thanks All,
Evan
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb

Posted 1 year ago

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

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
Evan,

That is very odd, because your button looks quite normal and the bit at the end with the &z=... tells QuickBase to redisplay the Parent record after saving.


Is there anything else unusual here in your setup. I can provide an alternative to that code which would probably work, but I'm not understanding what is different about your use case where the normal Add child button is not returning to the Parent.


What is happening now after you save the child?
(Edited)
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb

I see what you mean. Yes it does return back. Sorry for the confusion, I explained my setup incorrectly. I have a parent form that has a child table inside it with a button that leads to the grandchild. Is it possible to return back to the parent form after the grandchild record has been saved? Is there also a way to indicate on the button that a grandchild record has been created after it's been saved? I need an indication to avoid saving multiple records related to the same record. Thanks so much for the help!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
OK, now it makes sense.  The magic is using "&NextURL= ....

No problem,

var text URLONE = URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=API_GenAddRecordForm&_fid_17=" & URLEncode ([Record ID#]);

var text URLTWO = URLRoot() & "db/"  & [_DBID_the table name of the parent] & "?a=dr&rid=" & [Related Parent];

$URLONE
& "&NextURL=" & URLEncode($URLTWO)


I am using formula variables for readability and when you link the next thing for QuickBase to do, you need to URLEncode it.  Not sure why, but that's the syntax to make it work.
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
i did update the fields and I am now receiving the error "Formula syntax error

There are extra characters beyond the end of the formula."

URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=API_GenAddRecordForm&_fid_17=" & URLEncode ([Record ID#])& "&z=" & Rurl()

  var text URLONE = URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=API_GenAddRecordForm&_fid_17=" & URLEncode ([Record ID#]);

var text URLTWO = URLRoot() & "db/"  & [_DBID_DAMAGE] & "?a=dr&rid=" & [Related Damage Parts Incidents2 - Related Incident];

$URLONE
& "&NextURL=" & URLEncode($URLTWO)

Am I missing something?

Thanks for your help!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
//You just need this part. this replaces your original formula.  



var text URLONE = URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=API_GenAddRecordForm&_fid_17=" & URLEncode ([Record ID#]);

var text URLTWO = URLRoot() & "db/"  & [_DBID_the table name of the parent] & "?a=dr&rid=" & [Related Parent];

$URLONE
& "&NextURL=" & URLEncode($URLTWO)
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
Fantastic! The formula does return me back to the parent table but the only problem now is if my parent table houses multiple records in the child table, it returns me back to a different parent record every time I save a grandchild record.



Below is the child table inside the parent form leading to the grand child record button



Thank you!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
Now I am confused again as to what the problem is.

Can you describe your relationships and use the real names of the tables?. And then explain using the real names of the tables what the problem is?
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
Sorry for the confusion. I have a Damage table (Parent) that has a child table (Damage Parts) embedded in the parent table. My Damage Parts table inside the parent form has a button that leads to the grand child table (Root Cause) for every row in the table.

Child table (Damage Parts) in the Parent Table (Damage) the leads to Grand Child "Add Investigation" (Root Cause)


Table Record Flow
Damage >> Damage Parts >> Root Cause
(Once record is saved in Root Cause, I want to return back to original Damage incident)

The problem is once I create a grand child record through "Add Investigation" it returns me back to the parent table (Damage) but it's returning me to the different record.

I should note, in your formula I did reference record ID in the Parent Table for [Related Parent]; is this correct?

Thanks so much for the help!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
Can you post your actual code for the button?
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
Here is my current code...


var text URLONE = URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=API_GenAddRecordForm&_fid_17=" & URLEncode ([Record ID#]);

var text URLTWO = URLRoot() & "db/"  & [_DBID_DAMAGE] & "?a=dr&rid=" & [Record ID#];

$URLONE
& "&NextURL=" & URLEncode($URLTWO)
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
The problem is the the URLTWO

var text URLTWO = URLRoot() & "db/" & [_DBID_DAMAGE] & "?a=dr&rid=" & [Related Damage];

Stop and think about where is the user is when they push this button. They are sitting on a damage parts record. The record that you want to display is in the table above that which is called damage. The record ID that you want to display in the damage table is in fact the parent of the damage parts record. And that record ID is likely called [related damage].
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
Yes! That was the trick!!!

Now, instead of enabling the user to create multiple Grand Child Records (Root Cause) through the button, is there a way to disable the button from adding multiple records after an initial record has been created and possibly indicating on the button such as a color change to tell the user a record has been created? Essentially I just want the user to edit the original record through the button instead of creating new records.

Your help is greatly appreciated!!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
no problem,
you can make a summary field of the [# of root causes] on he relationships between damage parts and root causes.

Then instead of where it says

$URLONE
& "&NextURL=" & URLEncode($URLTWO)

replace that with

IF([# Root Causes]=0,
$URLONE
& "&NextURL=" & URLEncode($URLTWO))

The button will be blank after the first one is added.
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
This works great, but now the button disappears disabling any link to the created record. Is there a way to keep the link accessible in cases where the user needs to edit the record?

thanks!!
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
I don't understand.

The purpose of the button was to add a new record, not to edit an existing record. If the user needs to edit the record they should just edit the record with the edit pencil icon.
(Edited)
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
I needed to create an add button because I want to limit the access to only a few tables. The user only has access to the "Root Cause" form through the parent form "Damage" which is accessible only through the add button.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
Why not have a child table of the root cause on the damage parts table?
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
If I create a child table (root cause) on the damage parts table, will this require me to show all the field criteria on the table or can I have a button that will link the user directly to the form for editing?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
When you put th Report Link field type for the ROot Cases in the Damanage Parts form, you can specify that the child records ( just one record in your case) should appear directly on the form in a report. You may them create an unfiltered report to use to decide which columns (fields) of the rooot causes, you want to show to the users.

Users can then choose to either view the root because or edit it.
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
I do have several form rules setup on for my Root Cause form. Will these also work through a report link?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
If the user views a root cause Record, then the form rules will kick in regardless of how the user found their way to the record, so yes, your form rules will work.
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
Sorry, this is my first time using forms, tables and using Quickbase.

Will this allow the user to add a new record in root cause form and access that same record with ability to edit through the damage parts table? So far I seem to have everything in place but the accessibility to the record that was added in Root Cause.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
If you have a Report link field on the damage parts table and choose to show the root cause records directly on the form, then you also get a choice as to whether that embedded table is editable. That is a setting on the form property for that report link field.

If you make that editable, that means that when you edit the damage parts record the root causes become editable as well in what is called the grid edit format.

However if you have form rules they will not be applicable in grade edit format, and also of course there is a realistic limit to how wide you would want to make that embedded report in terms of the number of fields.

If you have a complicated root cause for him with many fields then it will be more practical to have the users click the pencil icon on the embedded report on the damage parts record and edit on the full form.

Just to confirm, can you confirm that you do in fact have an a better table of the root causes with the records directly showing on the damage parts record?
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
That's essentially what I did here. This is a child table (Damage Parts) embedded in the parent form (Damage). At the end to the right "Add Investigation" is the button link to the grandchild form (Root Cause). I want to avoid adding root cause fields since the table is already too long and I don't want those fields visible to all users.



Workflow direction example Damage >> Damage Parts >> Root Cause
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,006 Points 50k badge 2x thumb
Was that a question?