Forum Discussion

DonLarson's avatar
DonLarson
Qrew Elite
11 months ago

Mobile Redirect to a Report

I have an application that where the Users are answering questions on the mobile EOTI.    I have built links in the question records for executes an API call that records the answer.

I need the user to redirect back on the list of unanswered questions.   The RDR works great on the desktop

var text ReportLink = URLRoot() & "db/" & [_DBID_TEST_QUESTIONS] & "?a=q&qid=13&nv=1&v0="& Urlencode([Related Test]);

On the mobile I am not sure where they are landing but it is not my nice orderly report.   Anybody seen this behavior before and have a solution?



------------------------------
Don Larson
------------------------------
  • Customer support has told me that &NextURL and &rdr do not work on mobile. There is no way to direct someone on mobile, it will just land on the default landing spot each time. I suspect the only way to do it would be with a code page. I end up putting custom buttons on the page they land to get them to where I want. Everything mobile is infuriating....



    ------------------------------
    Mike Tamoush
    ------------------------------
    • DonLarson's avatar
      DonLarson
      Qrew Elite

      I put in a Support Ticket and got that confirmed.

      Did you try a Code Page in lieu of rdr?   Does it work?



      ------------------------------
      Don Larson
      ------------------------------
      • MikeTamoush's avatar
        MikeTamoush
        Qrew Commander

        I haven't tried the code page for that specific reason, but I did just recently in another thread, have Chayce help me and I was able to create a pause/refresh/redirect via a code page that worked on mobile.

        I bet we could use that exact code and just tell it to pause 0 seconds. Or, maybe we can get Chayce to help us make a very very simple code page where all it does is redirect to a passed variable. Ill try to post soon the code he helped with so you can modify and try that if needed.



        ------------------------------
        Mike Tamoush
        ------------------------------
    • MikeTamoush's avatar
      MikeTamoush
      Qrew Commander

      OK, I think you will see how you can modify this to your scenario, but here is how it works for me.

      (See attached for code page.)

      My Rich Text Button Code:

      var number MaxRID = [Max Record ID];  //I was using this redirect to a max RID
      var text newDbid = "btu5tehfu";  //I was redirecting to a specific table
      var text pageid = "61"; //my code page id

      var text URL = I have an Add Record API that Runs

      var text Redirect =
        URLRoot() & "db/" & "bpu98ejpu" & "?a=dbpage&pageid=" & $pageid & 
        "&newRID=" & ($maxRID + 1) & //Pass this variable to code page
        "&newDbid=" & $newDbid;  //Pass any variables here to code page.

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

      So above you can see how I pass variables to the code page. I suspect you can just pass the number of the report or what not.

      Below is the important part of the code page. See my comment of the important line that you are fussing with. Also how to set the pause to 0.

      **I know that somehow there is a very basic code page to simply redirect, and eliminate the pause and everything. I am going to look for something like that, but maybe you can modify this for now?

      function Run() {
              let urlParams = new URLSearchParams(window.location.search);
              let rid = urlParams.get('newRID');
              let dbid = urlParams.get('newDbid');
              let yourRealm = "sesgroup";
           let url = `https://${yourRealm}.quickbase.com/db/${dbid}?a=dr&rid=${rid}` //modify this line as needed. This is your redirect.
              if( dbid && rid ) {
                setTimeout(() => {
                  window.location.replace(url)
                }, 1000) //the 1000 is the milliseconds it pauses. Set this to 0?
              } else {
                console.log("something went wrong with your parameters", {dbid, rid, yourRealm, url})
              }
          }



      ------------------------------
      Mike Tamoush
      ------------------------------

      • MikeTamoush's avatar
        MikeTamoush
        Qrew Commander

        This code page is just called run and refresh. I bet it can be modified to return to a specific spot. Then its the same, but without the pause. This is from the Magic Buttons app

        <!DOCTYPE HTML>
        <html lang="en">
        <head>
            <meta charset="UTF-8">
            <title>Title</title>
        </head>
        <style>
        .loader {
          border: 16px solid #f3f3f3;
          border-radius: 50%;
          border-top: 16px solid #3498db;
          width: 120px;
          height: 120px;
          -webkit-animation: spin 2s linear infinite; /* Safari */
          animation: spin 2s linear infinite;
          display: block;
          margin-left: auto;
          margin-right: auto;
        }

        /* Safari */
        @-webkit-keyframes spin {
          0% { -webkit-transform: rotate(0deg); }
          100% { -webkit-transform: rotate(360deg); }
        }

        @keyframes spin {
          0% { transform: rotate(0deg); }
          100% { transform: rotate(360deg); }
        }
        </style>
        <body>
        <script src = 'https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js'> </script>
        <script>
            function Run() {
                let urlParams = new URLSearchParams(window.location.search);
                let url = urlParams.get('url');


            fetch(url, {
              method: 'post',
              mode: 'no-cors',
              headers: { 'Content-type': 'text/plain' }
            }).then((response) => {
                window.location.href = document.referrer;
            })

            }
            Run();
        </script>



        ------------------------------
        Mike Tamoush
        ------------------------------