Skip to main content
Question

Formula URL button - save and redirect

  • October 25, 2018
  • 0 replies
  • 3004 views

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
This topic has been closed for replies.

  • Registered
  • October 25, 2018
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:




QuickBaseJunkie
Forum|alt.badge.img+15
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


Thanks Dan!

I'm getting a syntax error on the period in the first line of the script.
Is there a change that needs to be made to the code?

Elisha, there is possibly an easier solution.

Your "add record" can specify where to go to upon Save.  ie the NextURL.

var text ADD = URLRoot() & "db/" & [_DBIDxxxx] & "?API_GenAddRecordForm&ifv=1":

var text RedirectTo = the url to redirect to;

$ADD
& "&NextURL=" & URELEncode($RedirectTo )



Hi there

My apologies for the delayed response. I'm new to javascript & quickbase and at the time of my initial posting these responses were beyond my skill level. 

I've advanced a little and decided to give these solutions another go. I�m not sure how & where to plug in these different lines of code. 

I tried putting Dan�s code 
1) directly into a formula-url field and I get a syntax error. 
2) directly into a formula-rich text I�d be redirected to ibm.com whenever I viewed a record
3) into a javascript page and loading it via iol and it would save the record but the redirect wouldn�t work

Similar challenges with Sharons & QBChampions solutions. I'm no sure how/where to put together and plug in the code.

I've had a bunch of success using some IOL scripts for other issues.

Any guidance on how to plug in your answers?

Thanks!

Try my suggestion, it�s stupid simple.