URL button to populate a field with the current user

  • 0
  • 1
  • Question
  • Updated 2 months ago
  • Answered
Hi There,

I currently have a url button that populates a certain field with the user that last modified the record.  

I need some help to change it from the user the last modified the record to the current user that pushes the button.

is there anyway to modify the below for the above requirement?


var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]

& "&_fid_30=" & URLEncode([Last Modified By]);


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

oliver mah

  • 850 Points 500 badge 2x thumb

Posted 2 months ago

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

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
& "&_fid_30=" & URLEncode(User());
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
hmmm..that's what I thought, i tried that but it doesn't put anything into field 30. still blank
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
Are you saying that the button did work properly for the [Last Modified by].  Do you have application tokens disabled?

You can also try this, as this is the format I usually use myself for Userid field types.

& "&_fid_30=" & ToText(User());
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
correct - the button worked fine when it was [last modified by]

app tokens are enabled.
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
Does your full formula provide an app token?  Have you posted your full formula?
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
here's the full formula

var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]

& "&_fid_30=" & URLEncode([Last Modified By]);


"javascript:" &
"$.get('" & 
$URL & 
"',function(){" &
"location.reload(true);" &
"});"
& "void(0);"
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
OK, so there is no way that the formula can work if your app is requiring Application Tokens.  You need to either turn off the need for Application Tokens or else provide on in the formula by adding in a line like,


var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]
& "&apptoken=xcxcxcxcxcxcxcxcxcxcxcx"
& "&_fid_30=" & URLEncode([Last Modified By]);


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



Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
ah...some reason app token on the home settings on the app was click on.  Thanks for all your help your first solution works just fine now.
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
so in the future if my app application tokens need to be turned on then adding this line will suffice?

& "&apptoken=xcxcxcxcxcxcxcxcxcxcxcx"

Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,436 Points 50k badge 2x thumb
Well, yes, that Syntax, but I assume that you realize that you need to go to "Manage Application Tokens" and click the button to create an Application Token for your app to use in URL formuals. 

ie  "xcxcxcxcxcxcxcxcxcxcxcx"

will not be the one that works for you!
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
haha - yes definitely undesrtand that part - thanks :)