Discussions

 View Only
  • 1.  JavaScript Warning, How can I get this working again?

    Posted 15 days ago
    I have a button that when clicked changes a Date/Time field (57) to when the button was clicked.  I am now getting a JavaScript warning when I open the properties window of the button field.  How can I get this working again?
    Thanks,
    Brian



    ------------------------------
    Brian Dunk
    ------------------------------


  • 2.  RE: JavaScript Warning, How can I get this working again?

    Posted 15 days ago
    Hello. You can't use JavaScript in url formulas. You need use a code page.

    Thank you

    Marcelo Benavides Torres 





  • 3.  RE: JavaScript Warning, How can I get this working again?

    Posted 15 days ago
    Existing JavaScript URL formula buttons will continue to run indefinitely. But as you can see they are no longer editable. If you post your actual code and not just a screenshot I will show you how to change that code to have the same effect but not using JavaScript.  

    Here for example is how we do it now.  Note the new syntax for how to refresh the page.

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

    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

     
    $Approve
    & "&rdr=" & URLEncode($RefreshPage)

    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------



  • 4.  RE: JavaScript Warning, How can I get this working again?

    Posted 15 days ago
    Here is my current code:

    Thanks for the help.

    var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"
    & "&rid=" & [Budget item ID#]
    & "&_fid_57=" & ToText(Now());


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

    ------------------------------
    Brian Dunk
    ------------------------------



  • 5.  RE: JavaScript Warning, How can I get this working again?

    Posted 15 days ago
    var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"
    & "&rid=" & [Budget item ID#]
    & "&_fid_57=" & ToText(Now());


    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

     
    $URL
    & "&rdr=" & URLEncode($RefreshPage)


    As as side note there is a nuance about the use of Now(). 

    if you replace the line with this

    & "&_fid_57=now;

    The effect will be to populate the field with the moment that the user actually clicks the button as opposed to when the button loaded on the screen.

    In many cases it's good enough to be close but if you were writing an application where users were say clocking in and clocking out on a time card system then you want to record the time they actually clicked the button and not perhaps a stale date/time when the page loaded.  


    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------



  • 6.  RE: JavaScript Warning, How can I get this working again?

    Posted 15 days ago
    Ok so I pasted the new code in.  When I click the button now I get the following:



    ------------------------------
    Brian Dunk
    ------------------------------



  • 7.  RE: JavaScript Warning, How can I get this working again?

    Posted 14 days ago
    You will either need to disable the need for application tokens by gong into the Settings for the app and then properties, or else create an application token and then insert a line like this where the xxxxx is replaced by the app token.

    If you were not sure what an application token is you probably don't need to have that extra layer of security in your app and you can disable it.  The exception might be if you were dealing with healthcare data.  But in the end it's your call whether you want the extra layer of security.  


    var text URL = URLRoot() & "db/" & Dbid() & "?act=API_EditRecord"
    & "&rid=" & [Budget item ID#]
    & "&apptoken=xxxxxxxxxxxxxxx"
    & "&_fid_57=now;

    var text RefreshPage = URLRoot() & "db/" & Dbid() & "?a=doredirect&z=" & Rurl();

     
    $URL
    & "&rdr=" & URLEncode($RefreshPage)


    ------------------------------
    Mark Shnier (Your Quickbase Coach)
    mark.shnier@gmail.com
    ------------------------------



  • 8.  RE: JavaScript Warning, How can I get this working again?

    Posted 14 days ago
    Yep...working now.  

    Thanks again!
    Brian

    ------------------------------
    Brian Dunk
    ------------------------------