Formula URL to generate new record on different table using specific form.

  • 1
  • 1
  • Question
  • Updated 2 years ago
  • Answered

Ok so I am trying to create a button that generates a new record in a different table while carrying over data from the existing table. I have other places that I have done this and I cannot seem to find where to get the ??????? from below. Does anyone have any advice? 


URLRoot() & "db/bj68rdvfx?a=API_GenAddRecordForm&_fid_???????" & URLEncode ([Record ID#])&"&dfid=10" & "&z=" & Rurl()

Photo of Matt

Matt

  • 60 Points

Posted 3 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
When you look at the target field ID and click on the Usage tab it will show you the field ID#.  Also on the field list of you click "options" towards the top right you can show the field ID# as well. Or right click on then field in the field list.
Photo of Matt

Matt

  • 60 Points
Ok so I located the field ID but I guess I am still confused on which field ID to use....How do I determine what field ID to use because I put in a few different options and none of them work....
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
Perhaps if you explain in words what you are trying to do, I can help with specifics, but in general  the field ID is the one that you are trying to pre-populate on the Add Record form
Photo of Matt

Matt

  • 60 Points
Someone from the customer service team got back to me on the support case and helped me answer my question. For context and completion of this thread I wanted to share what they helped me figure out...Just in case anyone else is looking for this answer. What I needed to get to was the related field between the two tables. I was trying to create a button that converted an applicant to an employee. To reduce data entry I wanted it to carry through the information, such as first name, last name, primary contact phone number, etc. I wanted those fields to come through so that I could write dynamic form rules to populate those fields automatically. Additionally I only needed a form on the employee table that had necessary fields so I created a form that was abbreviated. So the challenge was creating a Formula URL button that carried the information from the existing table to the new table and utilized the specific form that I had created. I accomplished this by locating the reference proxy field id and added to the formula that I put in my original post. Thus my formula above turned into this:

URLRoot() & "db/bj68rdvfx?a=API_GenAddRecordForm&_fid_133=" & URLEncode ([Record ID#])&"&dfid=10" & "&z=" & Rurl()

I did learn that this does not work without the = sign at the end of the fid. Not sure why but it is needed or it will not work. Hope this helps someone else out as much as it helped me!
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
What if I just want to change the 'Add New Record' form above a table in a parent record to start a New Record with a populated date? No need to open the record. 
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,542 Points 50k badge 2x thumb
Try this
URLRoot() & "db/" & [_DBID_the alias name of the table ] & "?a=API_GenAddRecordForm&_fid_xx="
& ToText([some date field])
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
The only field options are in the parent record. I'm not trying to pull the date from the parent record. I'm trying to create a new record with today's date in a field that's in the child record.
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
Use API_AddRecord, not GenAddRecordForm.

Then use the formula portion for the 
&_fid_xx="&URLEncode(Today())&"

If you want the date AND time use, 
&_fid_xx="&URLEncode(Now())&"
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
I'm getting a Formula syntax error:
Expected a valid expression after the "&"
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
You will still need the rest of the formula as well...

& URLEncode ([Record ID#])&"&dfid=10" & "&z=" & Rurl()
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
Can you show me what that looks like all together with the date and time field, because I'm getting an error that the parent record isn't found, and I don't speak code fluently :)
Photo of Matthew Neil

Matthew Neil

  • 31,678 Points 20k badge 2x thumb
var text URL= URLRoot() & "db/" & [_DBID_CHILD_TABLE_ID] & "?a=API_AddRecord&_fid_yy="&URLEncode ([Record ID#])&"&apptoken=zzzzzzzzzzzz&_fid_xx="&URLEncode(Today());

"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});" 
& "void(0);"


You will want to replace the "zzzzzzzzzz" with your app token,
change the fid_yy to the the field id of the [Related Parent] field on you child table.
 and the fid_xx with the field id number that you are looking to right the date to.

If you have trouble, copy your current equation from your "Add" button, and post it here (possibly as a new question because this one it getting long), and we can help you out.
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
Thanks so much Matthew! It worked, so I will end this string, and start a new one, because I do have another question. Thanks again!
(Edited)
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
One slight issue with this formula... the date is not populating, but I will include that in the next post.
Photo of Kelly

Kelly

  • 1,812 Points 1k badge 2x thumb
One slight issue with this formula... the date is not populating, but I will include that in the next post.