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.

  • 1
  • 1
  • Question
  • Updated 1 year 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 2 years ago

  • 1
  • 1
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
Is there a function I can add to the formula you provided that will allow a user access to the root cause record created by the add button? After a record is added I want to disable the user from adding multiple records to the same row and only allow access for editing the record that was created.


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 Incident];

 

$URLONE

& "&NextURL=" & URLEncode($URLTWO)
You make make a summary of the minimum of the Record ID# of the root cause record.  Call it [Record ID# of the Root Cause]

Then change the button to this (not tested)

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 Incident];

var text ADD =  

$URLONE

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

var text EDIT = URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=dr&rid=" & [Record ID# of the Root Cause];

IF([Record ID# of the Root Cause]>0, $EDIT, $ADD)
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
I've created "Record ID# of the Root Cause" and made it a summary in (Damage Parts) Table and I have updated the formula in the add button. Everything seems to take, but after creating a root cause record the button does not allow me to edit and does allows me to keep adding records. Is the If statement for the edit/add part of the formula for the button? I have included that as well.
Please post your formula
Also, two more things.  Where do you want to leave the user after they save the root cause edit?

Also if you want to land the user on edit mode on the root case, this line needs to read as below (er instead of dr,   (er means edit record.  dr means display record)


var text EDIT = URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=er&rid=" & [Record ID# of the Root Cause];
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
This is the current formula I have for the "Add button" the leads to the root cause form.


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 Incident];

var text ADD =  

$URLONE

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

var text EDIT = URLRoot() & "db/" & [_DBID_ROOT_CAUSE] & "?a=dr&rid=" & [Record ID# of the Root Cause];

If([Record ID# of the Root Cause]>0, $EDIT, $ADD)



So far it's doing everything correct but to enable the user to get back to the record in the root cause for that was created.

I want the leave the user in the parent form (Damage) since that's the only form table they will have access to.

I want the button to do 2 functions if possible; 1 enable the user to create the record in root cause and 2 after the record is created have access to the record without letting the users create multiple records for that same row.

Below was a workaround I was working on last night in case I don't get the button to function the way I need it. I would rather have access to add/edit function through "Add Investigation" button.

"Root Cause Related Damage Parts Incidents2" on the right Leads the user to the record that was added once a root cause has been saved. Top row had a record added, bottom row has not had a record added.




I feel like we're so close to solving this problem!!!
There must be a problem with that Summary field.


For a record with a child root cause record, what is the value on that field.
(Edited)
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
The value in the Summary field is 1 for [Record ID# of the Root Cause]

Here are the settings.

If the value in that Summary minimum Record ID is a 1, then the IF must be performing the EDIT formula variable. If you have changed the "dr " to "er" then pushing the button must be displaying the root cause Record in edit mode, which I thought is what you wanted.
Photo of Evan Fujikawa

Evan Fujikawa

  • 390 Points 250 badge 2x thumb
Yes, that is what I want. Once the root cause record is created I want the user to only to have access to edit that record and not able to keep "adding" new records.

What is currently happening is once the user creates a record for root cause the "add" button is not changing to edit mode and allows the user to keep adding new records.
I would have to see you app to debug the issue. I can be contacted via my website QuickBaseCoach.com

My response has been slow today as I have had a technical issues not being able to sign onto the forum today on most of my devices.
Photo of michael ward

michael ward

  • 130 Points 100 badge 2x thumb
What about the following:
var text URLONE=URLRoot() & "db/" & [_DBID_Tasks] & "?a=API_GenAddRecordForm&_fid_11=" & URLEncode ([Record ID#])& 
"&_fid_60=" & [03 IDD]& 
"&_fid_61=" & [03 EDD]&;

var text URLTWO=URLEncode("https://DOMAINNAME.quickbase.com/db/DBID2?a=q&qid=REPORT ID");

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

Getting an invalid formula after the semicolon following &[03 EDD]&
Please post your code.
Photo of michael ward

michael ward

  • 130 Points 100 badge 2x thumb
var text URLONE=URLRoot() & "db/" & [_DBID_Tasks] & "?a=API_AddRecord&_fid_11=" & URLEncode ([Record ID#])& 
"&_fid_60=" & [03 IDD]& 
"&_fid_61=" & [03 EDD];

var text URLTWO="https://capitalimpact.quickbase.com/db/bmddpcay2?a=q&qid=162";

$URLONE
& "&NextURL=" & URLEncode($URLTWO)
Photo of michael ward

michael ward

  • 130 Points 100 badge 2x thumb
just to note I did not get the XML error with the GenAddRecordForm only started after changed to AddRecord
Change NextURL to rdr

$URLONE
& "&rdr=" & URLEncode($URLTWO)
Photo of michael ward

michael ward

  • 130 Points 100 badge 2x thumb
Perfect.  You Are The Man.  I appreciate your help today.
Photo of Kelly

Kelly

  • 1,842 Points 1k badge 2x thumb
Mark, where would you add the dfid if you want to return to a specific parent form?
Kelly, 
it would be something like this

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

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

 

$URLONE

& "&NextURL=" & URLEncode($URLTWO);
Photo of Kelly

Kelly

  • 1,842 Points 1k badge 2x thumb
Thanks, Mark!