Discussions

 View Only
  • 1.  Redirects

    Posted 12-22-2020 12:43

    I was wondering if someone can clarify how the different redirects work/are used.

    & "&z=" & Rurl()   //This bit of magic will always return you to where you launched?? Can be used any time, or there are specific scenarios?

    & "&rdr=" & URLEncode(URL) //This seems to be the most literal version. You simply tell it exactly where to redirect? And can be used for nested redirects?

    //Below: this javascript seems to return you from where you launched? How does it differ from the first bit of code, and when do you use this javascript versus the first magic code?

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



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



  • 2.  RE: Redirects

    Posted 12-22-2020 12:58

    & "&z=" & Rurl()   //This bit of magic will always return you to where you launched?? Can be used any time, or there are specific scenarios?  This is used after a manual Add Record function.  The system needs to know where to land the user after they Save, on the newly created record in view mode? ... Or where the user was when they launched, for example typically a Parent form record or a report.

    "&rdr=" & URLEncode(URL) //This seems to be the most literal version. You simply tell it exactly where to redirect? And can be used for nested redirects?  Yes this is what we use for nested redirects.  The last rdr needs to land the user on a record or a report or a Home Page.

    //Below: this javascript seems to return you from where you launched? How does it differ from the first bit of code, and when do you use this javascript versus the first magic code?  This will execute a single URL call (not nested) and refers whatever page you are on.

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

    There is also "&NextURL=".  That is like & "&z=" & Rurl()  except rather than going back to where you came from, you control where to land the user after the save.  So it as also user after an Add Record URL.

    There is also this which will execute a single URL and do a quiet fade away pop up message as opposed to refreshing the page.

    "javascript:" &
    "$.get('" &
    $url &
    "',function(){" &
    "$.jGrowl('This Item has been put on PO CANCEL snooze', {life: 5000, theme: 'jGrowl-green'});" &
    "});" &
    "void(0);"

    Lastly there is this code to refresh the page after a 2 second delay (you set the time) to give Automations time to run.

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

    And lastly for completeness if you nest URLs or use the &NextURL they need to be successively URLEncoded.  So you slice off enough of that salami as you need.  The &NextURL would only need the two slices as the first will be the Add Record API and then the &NextURL would follow.

    $URLONE
    & "&rdr=" & URLEncode($URLTWO)
    & URLEncode("&rdr=" & URLEncode($URLTHREE))
    & URLEncode(URLEncode("&rdr=" & URLEncode($URLFOUR)))
    & URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLFIVE))))
    & URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSIX)))))
    & URLEncode(URLEncode(URLEncode(URLEncode(URLEncode("&rdr=" & URLEncode($URLSEVEN))))))



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



  • 3.  RE: Redirects

    Posted 12-22-2020 14:02

    Thanks this is great!

    I think the only thing I am still not completely following is NextURL versus the standard &rdr=. When would you use next, and when would you simply nest the &rdr?



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



  • 4.  RE: Redirects

    Posted 12-22-2020 14:04

    &NextURL is only used directly after an API to Add Record.  It controls where to land the user after a manual SAVE.



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



  • 5.  RE: Redirects

    Posted 12-22-2020 12:59

    You're right on what those different snippets do. As to WHEN they should be used, that's going to depend on the need. If you want to redirect the user back where they came from, use the first option. If you need to redirect them to a new location OR simply refresh the current page, use the 2nd option. Regarding the JS snippet, though, I would urge you to not rely on that, especially since the same thing can be accomplished with standard functions.

    Example: You need to build a "Submit" button that selects a checkbox, captures the current date & time, captures the current User, and then simply refreshes the page. Instead of using JS, the native formula could be done like this:

    var text chk = "&_FID_68=" & "1";
    var text usr = "&_FID_65=" & URLEncode(User());
    var text time = "&_FID_65=" & URLEncode(Now());
    var text tk = "token";
    var text URL =  URLRoot() & "db/" & Dbid() & "?a=API_EditRecord&apptoken=" & $tk & "&rid=" & [Record ID#] &
        $chk  &
        $time &
        $usr &
        "&rdr=" ;
    var text Land = URLRoot() & "db/" & Dbid() & "?a=dr&rid=" & [Record ID#];
    
    "<a class='Vibrant Success' & href=" & 
    
       $url &
            
            URLEncode($land)
    
    
    & ">Submit</a>"


    ------------------------------
    Blake Harrison
    bharrison@datablender.io
    DataBlender - Quick Base Solution Provider
    Atlanta GA
    404.800.1702 / http://datablender.io/
    ------------------------------