Form Redirection on Save - Bug?

I notice the result.RedirectURL isn't working for me.
Modern SharePoint Online.
Using Chrome and/or Teams.
Form in webpart and/or panel.

Code runs, checked console.
I do get the desired result with "window.location.href"

fd.spSaved(function(result) {
    //simply replace this URL for redirection:
    result.RedirectUrl = "https://<tenant>.sharepoint.com/sites/StartCardsandSWMS/SitePages/Start-Card-Complete.aspx";
    window.location.href = "https://<tenant>.sharepoint.com/sites/StartCardsandSWMS/SitePages/Start-Card-Complete.aspx"; 
});

Maybe something broke?

Adam

Hello @AdamSmith,

Do you see any errors in the console?

Please try to completely clear the browser cache and try again.

Hello Nikitina,

I have added the below code and it hasn't worked:

//This code will direct users to the Submission Success Landing Page on Save
fd.spSaved(function(result) {
    //Add URl Below
    result.RedirectUrl =
        "https://test-site.com/submissionsuccess.aspx";
});

The code was added outside the fd.spRendered(function(){}) event and inside this event.

Console doesn't display any errors either after submitting the form.

@DryChips,

What version of the Plumsail Designer are you using? How do you open the form: in full screen, panel or from List or Library?

Please test this code and share the screenshot of the console output:

fd.spSaved(function(result) {
    var redirect = result.RedirectUrl;
    result.RedirectUrl = "";
    console.log(result);
    console.log(redirect);
});

image

Hi @Margo looks like it does not redirect when used in the webpart. It does redirects if I open it the form from the list. On the site page I'll only receive the submission confirmation.

Hello @aseem,

RedirectUrl is ignored inside a panel. You can redirect users to another page using this code:

 fd.spSaved(function(result) {
    window.location.href = "Page_URL"; 
});

Hello @Margo - I am picking this up late I know by this is a problem I am having too and can’t get a workaround working at all.

I have a SharePoint site A New List Item link added as a web part to SharePoint site B.

In a custom button on site A, I have this as the Click code:

fd.spSaved(function(result) {
fd.field('policyagree').value = 'Yes';
fd.field('submitform').value = 'Submit Form';
result.RedirectUrl = "https://www.google.com";
});

return fd.save();

Where exactly would I use this? Again in site A, I have tried in JS and have tried in the Click for the custom button:

fd.spSaved(function(result) {
window.location.href = "https://www.google.com";
});

All is working but for the redirect. I welcome your suggestions as I need to prevent the submitter of the new form from seeing the Edit view upon submit, and I want them to be redirected out of SP to an external URL.

Thanks and I hope you are well :slight_smile:

Hello @shedev,

This code should work:

fd.spSaved(result => {
    // simply replace this url with yours:
    result.RedirectUrl =
        'https://domain.sharepoint.com/sites/sitename/SitePages/ThankYou.aspx';
});

Use it alone in the JavaScript editor like so and test:

@Margo - I thought that would work too but here is what I am seeing:

SPO List (from a different site) embedded into this site as a webpart. The user fills out the form and submits.

In Plumsail Designer (latest version), a custom button is configured; the two field values are set that trigger a backend Power Automate condition to send emails and render PDF copies of the completed form.

In Plumsail Designer I have added your suggested block in the JS panel.

Back in the SPO webpart, the user submits the New form and no redirect happens, rather a gray block that obscures what I assume are the List rows. If I refresh/reload the web browser (Chrome OSX), it loads the new form again. Ideally it would redirect or simply close the web browser tab entirely.

Hello,

Thank you for more details. RedirectUrl works only for a from in full screen mode.

For a form in a web part, you can use this code to redirect to another page after submission:

fd.spSaved(result => {
    window.location.href =
        'https://google.com/';
});

Another option is to hide the form or some blocks with jQuery by CSS class like so:

fd.spSaved(result => {
    $('.fd-form').hide();
});

@Margo - I thank you so much for this helpful guidance. Upon closer inspection, the person who designed this SPO page has embedded this for in as an iframe, not via web part as I has first thought, so it involves cross-site URLs. I am assuming the imbedded iframe New Form URL won’t support a redirect within the iframe window.