Discussions

Expand all | Collapse all

Button to toggle a checkbox in report

Matthew Neil04-25-2018 13:34

QuickBaseCoach Dev./Training08-24-2018 16:29

  • 1.  Button to toggle a checkbox in report

    Posted 04-23-2018 21:34

    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?



  • 2.  RE: Button to toggle a checkbox in report

    Posted 04-25-2018 13:34
    Like this?



  • 3.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 16:03

    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);"



  • 4.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 16:07
    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)];


  • 5.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 16:25
    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. 


  • 6.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 16:29
    Can you post your complete code.  It should work.


  • 7.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 16:51

    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);"



  • 8.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 16:55
    see if this works for the javascript

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


  • 9.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 17:12

    Yeah, it didn't like that.  When I replaced my javascript code with this, I got a blank page that just says "[object Object]". 


  • 10.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 17:21
    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);"



  • 11.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 17:30
    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.


  • 12.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 18:42
    Dan, in my experience, the button code is refreshed when the record refreshes, right?


  • 13.  RE: Button to toggle a checkbox in report

    Posted 08-24-2018 18:44
    I will follow up later. I answered in haste and have to double check what I wrote!


  • 14.  RE: Button to toggle a checkbox in report

    Posted 08-30-2018 20:01
    It still seems to stop toggling the checkbox on the 3rd click.  I have even waited a few mins and tried gain to confirm that there is no timing issue.  No luck.  Is there another way to approach this?  I need a simple way for my manager to remove a record from his view. 


  • 15.  RE: Button to toggle a checkbox in report

    Posted 08-30-2018 20:25
    Are you trying to refresh a particular report after each click?


  • 16.  RE: Button to toggle a checkbox in report

    Posted 08-30-2018 20:28
    You can use this syntax

    Define URLONE as the code to update the checkbox.

    Define URLTWO as the report.

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


  • 17.  RE: Button to toggle a checkbox in report

    Posted 08-30-2018 20:29
    Yes, the button displays in a report and I would like the report to refresh. 


  • 18.  RE: Button to toggle a checkbox in report

    Posted 08-30-2018 20:36
    So URLONE would be this

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

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

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

    var text URLTWO=
    URLRoot() & "db/" & Dbid () & "?a=q&qid=xx;

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

    Fill in xx with the report id#


  • 19.  RE: Button to toggle a checkbox in report

    Posted 08-30-2018 21:13
    Whooooooot!!!    This seemed to have worked.  I hit the button 20 times and it worked every time.  Thanks for sticking with me and the great help!!!!


  • 20.  RE: Button to toggle a checkbox in report

    Posted 08-30-2018 21:20
    Thx for letting me know.it worked.


  • 21.  RE: Button to toggle a checkbox in report

    Posted 11-14-2018 20:21
    I'm trying the same thing with a slightly different take with a pop up display after clicking.  However, The button is not toggling the checkbox field.  Below is my code:

    var bool NewToggle = If ([Toggle Submit] = true, false, true);

    var text URL = URLRoot() & "db/" & "?act=API_EditRecord&rid=" & [Record ID#] & "&_fid_214=" & $NewToggle & "apptoken=jzbh5tctc9cbhb5dkskndwjcgca";

    "javascript:" &
    "$.get('" & 
    $URL & 
    "',function(){" &
    "$.jGrowl('Your project proposal has been submitted', {life: 5000, theme: 'jGrowl-green'});" &
    "});" &
    "void(0);"


    fid_214 is the [Toggle Submit] field.  not sure where i'm going wrong.  

    Thanks


  • 22.  RE: Button to toggle a checkbox in report

    Posted 11-14-2018 21:13
    The problem  is here
    & "apptoken=jzbh5tctc9cbhb5dkskndwjcgca";
    & "&apptoken=jzbh5tctc9cbhb5dkskndwjcgca";


    The trick to debugging that is to do this, which I suggest that you do before correcting the bug so you learn how to debug.

    Comment out the javascript stuff and just run the URL



    var bool NewToggle = If ([Toggle Submit] = true, false, true);

    var text URL = URLRoot() & "db/" & "?act=API_EditRecord&rid=" & [Record ID#] & "&_fid_214=" & $NewToggle & "apptoken=jzbh5tctc9cbhb5dkskndwjcgca";


    $URL

    //"javascript:" &
    //"$.get('" & 
    //$URL & 
    //"',function(){" &
    //"$.jGrowl('Your project proposal has been submitted', {life: 5000, theme: 'jGrowl-green'});" &
    //"});" &
    //"void(0);"


    That will expose the error message which will be complaining about missing app token, and then that would been a clue for you about the missing &



  • 23.  RE: Button to toggle a checkbox in report

    Posted 08-30-2018 20:53
    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.