Jump to content

Redirect on Submit


Recommended Posts

I am trying to create a custom Redirect in my DataPage.

First off, I have a dropdown which the user will select the value from. If the user select A then he should be redirected to DataPage X, if the user select B then redirect to DataPage Y, if the user selected option C then should be redirected to DataPage Z.

 Pseudo:

If (dropdown.option =='A') {

return.redirect(https://DataPageX);

    elseif (dropdown.option == 'B') {

return.redirect(https://DataPageY);

    elseif (dropdown.option == 'C') {

return.redirect(https://DataPageZ);

}

else {return 'Invalid';}

}

}

 

Link to comment
Share on other sites

Hi @Perzival

This can be achieved using JavaScript. You may just want to use Switch method on that. Here's an article: https://www.w3schools.com/js/js_switch.asp

Switch method example:

<script>

document.addEventListener('FormSubmitted', function(event) {

switch (document.getElementByClassName('cbFormSelect').value); {
  case A:
    window.location="https://google.com";
    break;
  case B:
    window.location="https://youtube.com";
    break;
  case C:
     window.location="https://gmail.com";
    break;
}
});
</script>


Note: If you are using a field that is created from the table then make sure to save your URL's in that particular field. If you're using a Virtual field, you may enable custom values and insert your URL's in that field.

Important

You should pass the field's parameter on exit then choose "go to another page" at the last part of submission. From the URL field, paste the parameter and hit finish.

 

Cheers,

~ H

Link to comment
Share on other sites

  • 2 years later...
  • 7 months later...

Use Javascript:

window.location.replace('http://example.com');

It’s better than using window.location.href = ‘http://example.com’;

Using replace() is better for javascript redirect because it does not keep the originating page in the session history, meaning the user won’t get stuck in a never-ending back-button fiasco.

If you want to simulate someone clicking on a link, use window.location.href

If you want to simulate an HTTP redirect, use window.location.replace

You can use assign() and replace methods also to javascript redirect to other pages like the following:

location.assign("http://example.com");

The difference between replace() method and assign() method(), is that replace() removes the URL of the current document from the document history, means it is not possible to use the “back” button to navigate back to the original document. So Use the assign() method if you want to load a new document, andwant to give the option to navigate back to the original document.

 

Link to comment
Share on other sites

  • 1 month later...

Hi - Just an update, you may now use Virtual Field and Calculated Value on this workflow.

You may use a Virtual Field as a holder or identifier of the value from the dropdown and then set the Form Element as Calculated Value. In the Formula, you may use a CASE WHEN statement like:

CASE WHEN [@FIELDNAME] = 'value'
THEN 'https://www.google.com/'
WHEN [@FIELDNAME] = 'value 1'
THEN 'https://caspio.com/'
ELSE
https://www.youtube.com/
END

After setting up the formula, on the Destination and Messaging configuration screen, set the Destination after the record submits to 'Go to a New Page'. Lastly, in the Page URL, call the Virtual Field from the field picker.

For reference, you may check these links:

https://howto.caspio.com/datapages/datapage-components/virtual-fields/
https://howto.caspio.com/datapages/datapage-components/calculated-values/
https://howto.caspio.com/function-reference/
https://howto.caspio.com/datapages/forms/submission-forms/#:~:text=to make conditional.-,Destination and Emails,-Here you can

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...