Discussions

Expand all | Collapse all

JS code in the URL formula field

  • 1.  JS code in the URL formula field

    Posted 08-23-2021 09:42
    Hey,
    There are several URL formula fields in my application. They were created a couple of weeks ago and work great.
    Today I was surprised that QuickBase no longer allows me to edit them.
    How to solve this problem?



    ------------------------------
    Andrew S
    ------------------------------


  • 2.  RE: JS code in the URL formula field

    Posted 08-23-2021 09:48
    Edited by Austin K 08-23-2021 09:48
    By replacing the JavaScript with something else or leaving it be and letting it work. They no longer support JavaScript unless it is in a code page. You can explore code pages or service workers for an alternative. Service workers would be the more powerful one that would be able to make some of the same changes as you do now.

    For your exact formula here you are just making it reload the page which there is already a replacement for.

    https://community.quickbase.com/blogs/evan-martinez1/2021/07/09/alternatives-to-common-javascript-insertion-techni?CommunityKey=d860b0f8-6a48-487b-b346-44c47a19a804&tab=recentcommunityblogsdashboard

    https://community.quickbase.com/blogs/evan-martinez1/2021/07/15/javascript-upcoming-formula-rich-text-field-change?CommunityKey=d860b0f8-6a48-487b-b346-44c47a19a804&tab=recentcommunityblogsdashboard


  • 3.  RE: JS code in the URL formula field

    Posted 08-23-2021 11:07
    There is simple native replacement for what that URL formula is doing. Please post the code by copy paste and we can help you.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 4.  RE: JS code in the URL formula field

    Posted 08-23-2021 11:12
    var Number XXX = If([Active], 0,1);

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

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

    ------------------------------
    Andrew S
    ------------------------------



  • 5.  RE: JS code in the URL formula field

    Posted 08-23-2021 11:18
    this should work

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

    & "&apptoken=d7f7g4xdisdv7fdgjvh95d4d3xzc"
    & "&_fid_99=" & $XXX;

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

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

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------



  • 6.  RE: JS code in the URL formula field

    Posted 08-23-2021 16:20
    Thanks Mark, it works fine. Is it any way to redirect and scroll down to the record that was modified?

    ------------------------------
    Andrew S
    ------------------------------



  • 7.  RE: JS code in the URL formula field

    Posted 08-23-2021 16:34
    ... no, not that I know of, unless it behaves that way in the old report style (ie use the old report), I don't have time to test that right now.

    ------------------------------
    Mark Shnier (YQC)
    mark.shnier@gmail.com
    ------------------------------