Forum Discussion

GBab's avatar
GBab
Qrew Member
4 years ago

Converting Buttons to Rich Text for Mobile

I have several buttons that are currently formula URL buttons and I need to convert them to Formula Rich Text buttons because they do not work on mobile.  The code works api_editrecord works the only issue is that it does not save the form before running the api_editrecord. How do I get the rich text button to save before running the api_editrecord.

If([Daily Pilot Log Status]="Submitted-Pending Vendor Approval",

var text URL = URLRoot() & "db/" & [_DBID_DAILY_PILOT_LOGS] & "?a=API_EditRecord&rid="&[Record ID#]
& "&_fid_150=" & URLEncode("Approved")
& "&_fid_152=" & Now()
& "&_fid_151=" & URLEncode(User());

var text rdr = URLRoot() & "db/" & Dbid() & "?a=showpage&pageid=3";
"<a style='width: 150px;border-color:black; font: Arial; text-decoration: none; background:#37a237;color:white;' class='btn btn-sm btn-primary' href='#'" &
"onclick= \"window.location.replace('" & $URL & "&rdr=" & URLEncode($rdr) & "');\"" &
">Approve</a>")



------------------------------
C G
------------------------------

3 Replies

  • KirkTrachy1's avatar
    KirkTrachy1
    Qrew Assistant Captain
    Christopher: 

    You can do this with a Formula URL and if I read your question right, if you want the page to be saved before doing the API_EditRecord, you could do it with javascript but let's try it with a Formula URL that doesn't require javascript.

    You will want to turn on: Learn more located under App Properties.  Also, only a Formula URL field will save the parent record whilst you navigate away from a changed record.  It won't save the record if you use a formula rich text field.  Also, even if you use a formula url field, and you are on a parent record and nothing has changed on that record, you will be redirected to your rdr= url but the form doesn't see any changes so it will redirect without saving. (just a few learned lessons).

    You will want to create a formula url field and use the following:

    URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&apptoken=cpaz2k7njc4ifc24muhvc749ast&rid="&[Record ID#]
    & "&_fid_102=" & URLEncode("Approved")
    & "&_fid_103=" & Now()
    & "&_fid_105=" & URLEncode(User())&
    "&rdr="&URLEncode(URLRoot()&"db/"&Dbid() & "?a=dbpage&pageID=33")

    See video:
    https://drive.google.com/file/d/18luV8HqzNDoWwI2Qh7JcP-h32OC6uy-1/view?usp=drivesdk

    There is another way of doing this by invoking an onload to override the QuickBase redirect url but you already can use rdr= like the formula above.  Also QuickBase is migrating away the use of javascript in the buttons so I'm trying to honor that with a non-javascript option whenever possible.   You are welcome to comment and let your feeling be known at http://quickbase.uservoice.com.

    We talk about things like this during our daily M-F webinars "Office Hours" held at 1pm Eastern time.

    Hope that helps.

    Kirk

    ------------------------------
    Kirk Trachy , Senior Solutions Consultant
    QuickBase | 603-674-5454 M | ktrachy@quickbase.com
    ------------------------------
    • GBab's avatar
      GBab
      Qrew Member
      Hello @Kirk Trachy

      The issue is I need the button to work on mobile reports. Formula URL Buttons do not show on mobile reports.​

      ------------------------------
      C G
      ------------------------------
      • KirkTrachy1's avatar
        KirkTrachy1
        Qrew Assistant Captain

        Christopher:

        This is a formula rich text field option.  It will invoke the API_EditRecord, update the fields you want to update and then redirect to another page.

        "<a style=\"text-decoration:none; background: #f90; border-radius: 5px; color: #fff; display: inline-block; padding: 8px 8px; width:80px; text-align: center; text-shadow: none;  \"href='" & Dbid() & "?a=API_EditRecord&rid=" & [Record ID#] & "&apptoken=cpaz2k7njc4ifc24muhvc749ast&_fid_102=Approved&_fid_103="&Now()&"&_fid_105="&URLEncode(User())&"&rdr=" & URLEncode(URLRoot() & "db/" & Dbid() & "?a=dbpage&pageID=33")  &  "' target=\"_blank\" >Approve</a>"

         
        NOTE: This does work on Mobile reports but will not save the record first.  The ability to save automatically works only with a formula url field and as you have written, the formula url type of field doesn't show up on reports.  Please log a request for this functionality with our Uservoice.  Also, should you come up with a solution or work around, please update the post.



        ------------------------------
        Kirk Trachy , Senior Solutions Consultant
        QuickBase | 603-674-5454 M | ktrachy@quickbase.com
        ------------------------------