Forum Discussion

MackenziePhilli's avatar
MackenziePhilli
Qrew Trainee
5 years ago

URL Button that changes field in the same record

This should  be very simple but for whatever reason is NOT working in my app. I'm not sure if there's some settings or restrictions I'm unaware of.

Trying to make a button that when clicked, changes a field from no to yes. My code is:

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

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

I'm not sure if it has something to do with the App token, the "allow app tokens" in from then app properties, my code, etc, but the button does nothing to field.

I tried the same formula in another table, but changed to the correct field ids, and when pressing the button it would change the target field of a different record from the table. I've done the same code in a different app and it works fine. Please help!!

------------------------------
Mackenzie Phillips
------------------------------
  • I would encourage you to try it without the JavaScript and instead, call the API directly, like this:

    var text chk = "&_FID_12=";
    var text tk = "token";
    "<a class='Vibrant Success' & href=" & URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&apptoken=" & $tk & "&rid=" & [Record ID#] & $chk & "Yes" & "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#]) & ">Check Box</a>"​


    ------------------------------
    Blake Harrison
    bharrison@datablender.io
    DataBlender - Quick Base Solution Provider
    Atlanta GA
    404.800.1702 / http://datablender.io/
    ------------------------------
    • MichaelTamoush's avatar
      MichaelTamoush
      Qrew Captain
      Here is code from Kirk Trachys Magic Buttons. This example is to check a checkbox then display the record using  formula URL

      URLRoot() & "db/" & Dbid() & "?a=API_EditRecord" &
        "&rid=" & [Record ID#] &
        "&apptoken=d9eascudwjxs2sesxkjccwgtq9r" &
        "&_fid_101=1" &
        "&rdr=" &
        URLEncode(URLRoot() & "db/" & Dbid() &
        "?a=dr&rid=" & [Record ID#])

      ------------------------------
      Mike Tamoush
      ------------------------------
  • Mackenzie
    try this

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

    & "&_fid_12=Yes";

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



    The problem with your original formula was that you were trying to put the app token into where it was expecting the rid (Record ID)

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------