How to trigger Save button on New form and open the Edit Form

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

02 Mar 2018

Dear bnunweiler,
Not sure why this happens, perhaps the Item is submitted twice, you can try to include a simple check to prevent it:

Code: Select all

var saving = false;

fd.onsubmit(function() {
    if (!saving){
        saving = true;
        //execute the rest of the code here
    }
});
Cheers

bnunweiler
Posts: 11
Joined: Tue Jun 10, 2014

02 Mar 2018

Thanks, but this did not work.

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

05 Mar 2018

Dear bnunweiler,
Please, send us the code that you use on the New Form. We might've found the cause, but we'll need to see your code, so we can test it and make sure that it works as intended.
Cheers

bnunweiler
Posts: 11
Joined: Tue Jun 10, 2014

15 Mar 2018

Here it is:

fd.field('Title').value('TEMP VALUE');
var saving = false;
fd.onsubmit(function() {
if (!saving){
var uri = fd.setUrlParam(decodeURIComponent(window.location.href), 'FDRedirectWithID', 'fd_Item_Edit.aspx?ID=');
fd.sourceFormParam(uri);
return true;
}});
fd.save().click();

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

16 Mar 2018

Dear bnunweiler,
Please, use this instead, it should solve the issue:

Code: Select all

var location = window.location.href;
if (location.indexOf('FDRedirectWithID') < 0){
    fd.field('Title').value('TEMP VALUE');
    fd.onsubmit(function() {
            var uri = fd.setUrlParam(decodeURIComponent(window.location.href), 'FDRedirectWithID', 'fd_Item_Edit.aspx?ID=');
            fd.sourceFormParam(uri);
            return true;
    });
    fd.save().click();
}
Cheers

TKay
Posts: 11
Joined: Mon Jun 19, 2017

21 Mar 2018

can the above solution be used for a dialog popup form?

User avatar
Nikita Kurguzov
Posts: 889
Joined: Mon Jul 03, 2017

21 Mar 2018

Dear TKay,
Unfortunately, no, it's impossible to redirect users from dialog window. That's because when you close regular window, you can still run JavaScript while it closes and use it for redirection, but as soon as dialog window closes down, all scripts stop running and there is no way to redirect user after that.
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests