Get ID of the item created and redirect after submit

Discussions about Forms Designer for SharePoint 2013 / 2016 and Office 365.
Locked
metrovan
Posts: 16
Joined: Fri Feb 10, 2017

13 Feb 2018

Hi,

After adding a new item, I'd like to redirect the page to a URL such as: http://abc.com?ID=1234

Where 1234 is the ID of the item that just created.

Is it possible to do this?

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

14 Feb 2018

Dear Metrovan,
Yes, that is possible, check out this topic - viewtopic.php?f=1&t=1970
Cheers

metrovan
Posts: 16
Joined: Fri Feb 10, 2017

14 Feb 2018

Is there a way to just get the value of the ID?

I am inserting the form on a page, when using:

Code: Select all

fd.onsubmit(function() {
    var uri = fd.setUrlParam(decodeURIComponent(window.location.href), 'FDRedirectWithID', 'https://domain.sharepoint.com/sites/dev/subsite/SitePages/page.aspx?redirectedID=');
    fd.sourceFormParam(uri);
    return true;
});
The ID is always 1.

It only returns the correct ID when I am in the back end to add a new item.

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

14 Feb 2018

Dear Metrovan,
What do you mean? Try to use:

Code: Select all

fd.onsubmit(function() {
    var uri = fd.setUrlParam(decodeURIComponent(window.location.href), 'FDRedirectWithID', 'http://abc.com/?ID=');
    fd.sourceFormParam(uri);
    return true;
});
Add this code to JavaScript editor on the New Form and it should give you the result you are looking for. If it doesn't, please provide screenshots and some details of what goes on instead.
Cheers

metrovan
Posts: 16
Joined: Fri Feb 10, 2017

14 Feb 2018

I have that code in my javascript.

I exported and inserted the form onto a page as a webpart.
form.JPG
form.JPG (25 KiB) Viewed 1842 times

After the Next submit button, it redirected to the url i want but with ID=1, instead of the real item ID

Capture.JPG
Capture.JPG (9.37 KiB) Viewed 1842 times

It only gets the correct ID when I got to the list, and add the item by clicking on + New Item.

When I add the item on a form I exported and inserted on a page, it gets the wrong ID.

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

15 Feb 2018

Dear Metrovan,
Where exactly are you putting this JavaScript code? Also, can you tell me how you've published the page?
Cheers

Locked
  • Information
  • Who is online

    Users browsing this forum: No registered users and 13 guests