URL button change status

  • 0
  • 1
  • Question
  • Updated 4 months ago
  • Answered
I've created a buttong to change my status to complete.  What am have I done wrong?

I'm getting this error using this:
 

var text URLONE = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" &[Status]

& "&_fid_12=" & URLEncode("Completed"); 

var text URLTWO=URLRoot() & "db/"&Dbid()&"?a=dr&rid="&[Status];

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


This is the Error: 

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

<qdbapi>
<action>API_EditRecord</action>
<errcode>24</errcode>
<errtext>Invalid Application Token</errtext>
<errdetail>An Application Token must be supplied.</errdetail>
</qdbapi>
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb

Posted 4 months ago

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

QuickBaseCoach App Dev./Training, Champion

  • 51,326 Points 50k badge 2x thumb
There are two separate issues.

If you have chosen to require Application Tokens, that is a setting in the Advanced properties settings for the app.  I suggest just disabling the need for them by unchecking boxing that requirement.

If you read up on the Help text for application tokens  and decide that do want to use them, then you will need to add a line of code
& "&apptoken=xxxxxxxxxx"

For you actual code, you need to specify the Record ID# that you want to edit and display.


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

& "&_fid_12=" & URLEncode("Completed"); 

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

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


Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
Thanks so much that did it! 
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
actually one more question:

I've added he button to a report as well.  seems like when you click the button on the report it the page directs you to the specific record.  Is there anyway for it to just stay on the report and not direct you to the into that specific record?
Photo of QuickBaseCoach App Dev./Training

QuickBaseCoach App Dev./Training, Champion

  • 51,326 Points 50k badge 2x thumb
try this

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

& "&_fid_12=" & URLEncode("Completed"); 



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


 note that I renamed that first formula variable.  We no longer use the second formula variable.
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
This is fantastic - thanks so much for your help, works great.
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
I've now revised this to update a field with the User ID of the individual that pushes the button and it seems to be working just fine with the below.  However, was wondering if anybody had any suggestions to change this us so that it only displays the user name.  Currently is showing their email address:

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

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



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

QuickBaseCoach App Dev./Training, Champion

  • 51,326 Points 50k badge 2x thumb
There is a function called

UserToName([my user field])

Or you can also change the field properties of the user field to display the full name
Photo of oliver mah

oliver mah

  • 850 Points 500 badge 2x thumb
thank you!