Forum Discussion

GeorgeBramhall2's avatar
GeorgeBramhall2
Qrew Cadet
4 years ago

Syntax error in a Rich Text Formula

Can someone spot my syntax error in this formula? When I try to save it says rdr needs to preceded with a (, but that does not work. 

If([Sent Checkbox],"<a href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=dwh245kc9bvrzfcqkqfwmd876gjx&_fid_35=0& ("&rdr="&URLEncode(URLRoot() & "db/" & Dbid() & "?a=doredirect&z"= & Rurl())& "'><img src=\"https://images.quickbase.com/si/16/018-email_unread.png\"></a>","<a href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=dwh245kc9bvrzfcqkqfwmd876gjx&_fid_35=1& "&rdr="&URLEncode(URLRoot() & )"db/" & Dbid() & "?a=doredirect&z"= & Rurl()& "'><img src=\"https://images.quickbase.com/si/16/016-email_1.png\"></a>")

------------------------------
George Bramhall
------------------------------
  • try this ... but what I recommend is to use formula variables for each part of the IF result and then put them together in the IF

    I also recommend putting this into a formula variable


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

    If([Sent Checkbox],
    "<a href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
    & "&apptoken=dwh245kc9bvrzfcqkqfwmd876gjx&_fid_35=0"

    &

    "&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=doredirect&z"= & Rurl()

    & "'><img src=\"https://images.quickbase.com/si/16/018-email_unread.png\"></a>","


    <a href='" & Dbid() & "
    ?a=API_EditRecord&rid=" & [Record ID#]
    & "&apptoken=dwh245kc9bvrzfcqkqfwmd876gjx&_fid_35=1"
    & "&rdr="&URLEncode(URLRoot() & )"db/" & Dbid() & "?a=doredirect&z"= & Rurl()& "'><img src=\"https://images.quickbase.com/si/16/016-email_1.png\"></a>")


    if that does not work and you want to post back please copy and paste your error message.

    ------------------------------
    Mark Shnier (YQC)
    Quick Base Solution Provider
    Your Quick Base Coach
    http://QuickBaseCoach.com
    mark.shnier@gmail.com
    ------------------------------
    • GeorgeBramhall2's avatar
      GeorgeBramhall2
      Qrew Cadet
      Hi Mark,
      Thanks for the reply!
      It comes back saying expecting text (highlighting the & before the Rurl() in the var)
      var text refresh = URLEncode(URLRoot() & "db/" & Dbid() & "?a=doredirect&z"= & Rurl();

      If([Sent Checkbox],
      "<a href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
      & "&apptoken=dwh245kc9bvrzfcqkqfwmd876gjx&_fid_35=0"
      & $refresh
      & "'><img src=\"https://images.quickbase.com/si/16/018-email_unread.png\"></a>","
      <a href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
      & "&apptoken=dwh245kc9bvrzfcqkqfwmd876gjx&_fid_35=1"
      & $refresh & "'><img src=\"https://images.quickbase.com/si/16/016-email_1.png\"></a>")

      ------------------------------
      George Bramhall
      ------------------------------
      • MarkShnier__You's avatar
        MarkShnier__You
        Icon for Qrew Legend rankQrew Legend
        That button is actually quite complex.  You are trying to present two different hyperlinks, each doing a different URL plus a Page Refresh and two different images.  Unless you are a better coder than I am you have no hope of writing it in the syntax you wrote it in. 

        You really must break it down into pieces.  Yes it will be a lot longer formula, but its really just a lot of Copy and Paste.

        This tested OK and is easy to read and hence to debug.

        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

        var text UnToggleURL = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
        & "&apptoken=dwh245kc9bvrzfcqkqfwmd876gjx"
        & "&_fid_35=0";

        var text ToggleURL = URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#]
        & "&apptoken=dwh245kc9bvrzfcqkqfwmd876gjx"
        & "&_fid_35=1";

        var text UnToggleRefresh =
        $UnToggleURL
        & "&rdr=" & URLEncode($RefreshPage);

        var text ToggleRefresh =
        $ToggleURL
        & "&rdr=" & URLEncode($RefreshPage);


        var text UnreadImage = "<img src=https://images.quickbase.com/si/16/018-email_unread.png>";

        var text ReadImage = "<img src=https://images.quickbase.com/si/24/016-email_0.png>";

        var text UnReadHyperlink =
        "<a href=" & $UnToggleRefresh & ">" & $UnreadImage & "</a>";

        var text ReadHyperlink =
        "<a href=" & $ToggleRefresh & ">" & $ReadImage & "</a>";


        If([Sent Checkbox], $UnReadHyperlink, $ReadHyperlink)

        ------------------------------
        Mark Shnier (YQC)
        Quick Base Solution Provider
        Your Quick Base Coach
        http://QuickBaseCoach.com
        mark.shnier@gmail.com
        ------------------------------