Forum Discussion

ToddGriffith's avatar
ToddGriffith
Qrew Cadet
7 years ago

Button to toggle a checkbox in report

I have a report with a checkbox.  I would like to create a button on the report that would toggle the checkbox on or off, depending on it's current status.  I would like the toggle button to change labels (ie. True or False) based on the current value of the checkbox.  Finally, I'd like to have the report stay on the screen.  It can refresh, but I'd prefer it to remain at the report. 

This seems to be beyond my skill level.  Can anyone help me create this?

22 Replies

  • My current issue is that the button does not seem to work consistently.  It will toggle the checkbox the first time I click it, but will not toggle it on subsequent clicks.  Below is my code.  Any Ideas?
     
    var text XXX = If([MD Approval (2)]=false,"true",
    [MD Approval (2)]=true,"false");

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

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

  • either of these will work. The issue is that true and false are not text strings, they are boolean so they do not go in quotes.

    var text XXX = If([MD Approval (2)]=false, true, false);

    var text XXX = not [MD Approval (2)];
  • I had to change the "var text XXX" to "var bool XXX", otherwise it kept popping an error.  But this still doesn't solve my issue.  I hit the button and it toggled the checkbox.  I tried again and it toggled it successfully, third, fourth and fifth, it did not. 
  • Here you go.

    var bool XXX = not [MD Approval (2)];

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

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

  • see if this works for the javascript

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

  • Yeah, it didn't like that.  When I replaced my javascript code with this, I got a blank page that just says "[object Object]". 
  • I tested this and could not get it to fail.  I'm not sure  what else to suggest.  Any chance you were clicking too fast before the page got a chance to refresh

    var bool XXX = not [checkbox];

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

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

    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      The XXX user defined variabvle is evaluated only once so only the first toggle works.

      There might be a native solution but there certainly is a script solution.

      Unfortunately I am about to shut down for the weekend. Have a good one yourself.
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      Dan, in my experience, the button code is refreshed when the record refreshes, right?
    • _anomDiebolt_'s avatar
      _anomDiebolt_
      Qrew Elite
      I will follow up later. I answered in haste and have to double check what I wrote!
  • Hi Todd,

    Another alternative that might be helpful for checking the status of the checkbox is to instead use the numeric value that the checkbox fields utilize. 1 for True and 0 for false. So something like. 

    var numeric XXX = If([Checkbox]=1, 0,1);

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

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

    That way you are pushing the numeric value into your checkbox field to request the change which might process differently from the not syntax.