Fill out form with a click of a button

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

Hello, I am trying to create a button that would track attendance.. I was able to create a button that so far only enters the date but having trouble getting the clients information (name, date of birth) to automatically populate. Can someone help finish the formula to include the other fields, this is what I got so far


If(IsNull([Date]),

URLRoot() & "db/" & [_DBID_GENERATION_ATTENDANCE] & "?act=API_AddRecord&AppToken=g83d656rj4cj9hxes3cgp88x4"&

"&rdr=" & URLEncode(URLRoot() & "db/" & [_DBID_CLIENTS]),

"javascript:alert('This has already logged in.')")

Photo of Juan

Juan

  • 20 Points

Posted 2 years ago

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

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
Do you have fields on that record which contain that information?  ie the "clients information (name, date of birth)"
Photo of Juan

Juan

  • 20 Points
Yes I do, field names are First Name, Last Name and Date of Birth
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
This will create a record and advise the user

var URL = URLRoot() & "db/" & [_DBID_GENERATION_ATTENDANCE] & "?act=API_AddRecord"

& "&AppToken=g83d656rj4cj9hxes3cgp88x4"

& "&_fid_xx=" & URLEncode([First Name])

& "&_fid_yy=" & URLEncode([Last Name])

& "&_fid_zz=" & URLEncode([Date of Birth]);



If(IsNull([Date]),


"javascript:" &
"$.get('" & 
$url & 
"',function(){" &
"$.jGrowl('Attendance Record Created', {life: 5000});" &
"});" &
"void(0);"


)
Photo of Juan

Juan

  • 20 Points
Hi Mark, thank for taking the time to help me with the issue i am having... the formula is not working but that would be my fault cause I might have left out some information that might make a difference. I have created two tables, one has the clients information which includes the name and date of birth and the second table is more like an attendance log. I have already created a relationship between the two tables and would like the button to copy over the client info from table one to table two and enter the current date
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
If I understand you, you also want a date field populated with Today's date.

Is this what you want for the first part then?

var URL = URLRoot() & "db/" & [_DBID_GENERATION_ATTENDANCE] & "?act=API_AddRecord"

& "&AppToken=g83d656rj4cj9hxes3cgp88x4"

& "&_fid_xx=" & URLEncode([First Name])

& "&_fid_yy=" & URLEncode([Last Name])

& "&_fid_zz=" & URLEncode(Today());
Photo of Juan

Juan

  • 20 Points
Nice! thank you Mark.. for the cherry on top, is there a way we can make it return to the previous page after clicking the button
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
Sorry, I'm a bit confused now.  Can I see your whole formula.  Do you want the page that you were on to refresh?
Photo of Juan

Juan

  • 20 Points
URLRoot() & "db/" & [_DBID_GENERATION_ATTENDANCE] & "?act=API_AddRecord"

& "&AppToken=g83d656rj4cj9hxes3cgp87x3"

& "&_fid_21=" & URLEncode([Record ID#])

& "&_fid_18=" & URLEncode([First Name])

& "&_fid_19=" & URLEncode([Last Name])

& "&_fid_20=" & URLEncode([Date of Birth])

& "&_fid_6=" & URLEncode(Today())

After I click on the button, program will redirect me to another page that will give this message:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<qdbapi>
<action>API_AddRecord</action>
<errcode>0</errcode>
<errtext>No error</errtext>
<rid>766</rid>
<update_id>1478285125383</update_id>
</qdbapi>
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 65,310 Points 50k badge 2x thumb
You need to go back to my original answer and copy that format. I'm just in my iPhone now, but you need all that code. You are missing the second half if the code.

I will post back later if you are stuck.