Discussions

 View Only
Expand all | Collapse all

Formula URL button - save and redirect

QuickBaseCoach Dev./Training

QuickBaseCoach Dev./Training11-09-2018 20:32

  • 1.  Formula URL button - save and redirect

    Posted 10-25-2018 17:58

    Hi there

    I?ve created a form accessible to ?everyone on the internet? for our clients to submit service requests. I added ?&ifv=20? to the url to hide the qb branding. However, doing this causes the save button to become hidden. I created a formula url button that will save it  using this javascript I found on the forum:

    var text URL = "javascript:void(DoSaveAdd())";var Text Image = "<a id='saveButton' class='Vibrant Success' onclick='DoSaveAdd()' href='#'>Submit</a>";"<b href =" & $URL &">" & $Image & "</b>"

    My problem now is how do I get the page to redirect after the form is saved. Here?s a link to the form, you can try it and see what happens.

    https://sparkav.quickbase.com/db/bnzwm7ykp?a=nwr&ifv=20

    I'd like it to redirect to an external webpage. If that is not natively possible than I'd like it to redirect to a rich text page I've created in quickbase.

    Any help with this would be greatly appreciated!

    Thanks,
    Elisha


  • 2.  RE: Formula URL button - save and redirect

    Posted 10-25-2018 19:25
    Submit the form with script using FormData:

    var editform = document.getElementsByName("editform")[0];
    var formData = new FormData(editform);
    formData.set("subact", "save");

    window.onbeforeunload = null;

    fetch("bnzwm7ykp?a=FinishEditRecord", {
      body: formData,
      method: "POST",
      credentials: "include"
    }).then(function(response) {
      document.location.href = "https://ibm.com";
    });

    This script (1) creates a FormData object equivalent to the QuickBase form, (2) sets the subact hidden field to "save" and (3) submits the from via fetch which returns a promise. When the promise resolves, the page redirects to ibm.com.

    Speaking of promises, I got to get me a one of those big async yard signs:





  • 3.  RE: Formula URL button - save and redirect

    Posted 10-25-2018 19:34
    You can add a redirect in your formula by replacing $URL with

    $URL & "&rdr=" & $URLTWO

    You'll then need to add another variable for URLTWO (var text URLTWO = )

    You are correct that you cannot redirect outside of QuickBase, so URL TWO would be something like this (where the pageID=3 is replaced with your pageID).

    URLRoot() & "db/" & Dbid() & "?a=dbpage&pageID=3"; 

    -Sharon



  • 4.  RE: Formula URL button - save and redirect

    Posted 06-17-2019 23:56
    I was recently asked about the code I provided here and I have a better alternative using the onclick method below.

    var text SAVE = "onclick=\"$('#saveButton').click()";
    var text REDIRECT = URLRoot() & "db/" & Dbid() & "?a=dbpage&pageID=2"; 

    "<a class='Vibrant Success' & " & $SAVE & "; window.location.href=' "& $REDIRECT &" '\">SAVE & Go to Page</a>"


  • 5.  RE: Formula URL button - save and redirect

    Posted 06-20-2019 19:50
    You can actually do this without using JavaScript as well.

    You'll need to use the table setting called "Save parent record automatically when a child record is created." When this box is checked for your table, any time has the form open for adding / editing a record, and they click a link, they won't get the pop-up window asking if they want to save the record first. Instead, the user will see the "Saving" message briefly, then they will be redirected based on whatever link they clicked.

    You can use standard a Formula - URL here, which essentially becomes your own custom save button. Without needing to call DoSaveAdd.



  • 6.  RE: Formula URL button - save and redirect