Discussions

 View Only
  • 1.  URL Button to check/uncheck a check box

    Posted 05-24-2017 13:29
    Is it possible to use conditional logic with an api call? I would like to create a URL button to check or un-check a checkbox depending on the state it is in 


  • 2.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 13:48
    No Problem

    Here is an example of a URL Formula field

    var text NewCheckboxValue = IF([Status]="New","0","1");


    var text URL= URLRoot() & "db/" & [_DBID_TABLE_1] & "?act=API_EditRecord"
    & "&rid=" & URLEncode ([Record ID#])
    & "&_fid_7=" & $New Status
    & "&apptoken=" & "XXXX";

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

    That last stuff is just boilerplate code (as long as you name your formula variable URL) which refreshes the page.


  • 3.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 13:48
    Hi Jorden,

    Yes, you can.

    Please have a look at the sample formula:

    URLRoot() & "db/" & Dbid() & "?act=API_EditRecord&rid=" & [Record ID#]   & If([Checkbox]=true, "&_fid_101=0", "&_fid_101=1")   & "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#])

    Replace _fid_101 with your field Id and [Checkbox] field with your checkbox field name.

    Please let me know if this works for you and need any further help.

    Thanks,

    Gaurav


  • 4.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:10
    This did the trick, although it does redirect you into the record, I should have been more clear, I am wanting to do this from a table view


  • 5.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:14
    Jordan,

    Please have a look at the Mark Answer. He did the exact thing which you are asking. Also, that formula will work in all your scenarios whether you are triggering from the table or form it will redirect back to your original position. 

    Please go ahead with that.

    Thanks,
    Gaurav


  • 6.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:14
    Jordan, my solution will refresh the page you were on, be it a record or a report.


  • 7.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:16
    I am struggling to get this solution to work, 

    I am currently using 

    var text NewCheckboxValue = If([Priority]="New","0","1");

    var text URL= URLRoot() & "db/" & [_DBID_TASK] & "?act=API_EditRecord"
    & "&rid=" & URLEncode ([Record ID#])
    & "&_fid_32=" & $New Priority;

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


  • 8.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:18
    Replace "New" with True.


  • 9.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:20
    Use this:
    var text NewCheckboxValue = If([Priority]=True,"0","1");

    var text URL= URLRoot() & "db/" & [_DBID_TASK] & "?act=API_EditRecord"
    & "&rid=" & URLEncode ([Record ID#])
    & "&_fid_32=" & $NewCheckboxValue;

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


  • 10.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:28
    This did the trick, thank you guys!


  • 11.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:28
    Replace that with the Dbid()


  • 12.  RE: URL Button to check/uncheck a check box

    Posted 05-24-2017 14:34
    Cheers!


  • 13.  RE: URL Button to check/uncheck a check box

    Posted 07-24-2017 19:00
    What did you replace with Dbid()?