Page 1 of 1
Get ID of the item created and redirect after submit
Posted: 13 Feb 2018
by metrovan
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?
Re: Get ID of the item created and redirect after submit
Posted: 14 Feb 2018
by Nikita Kurguzov
Dear Metrovan,
Yes, that is possible, check out this topic -
viewtopic.php?f=1&t=1970
Re: Get ID of the item created and redirect after submit
Posted: 14 Feb 2018
by metrovan
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.
Re: Get ID of the item created and redirect after submit
Posted: 14 Feb 2018
by Nikita Kurguzov
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.
Re: Get ID of the item created and redirect after submit
Posted: 14 Feb 2018
by metrovan
I have that code in my javascript.
I exported and inserted the form onto a page as a webpart.
- form.JPG (25 KiB) Viewed 1843 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 (9.37 KiB) Viewed 1843 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.
Re: Get ID of the item created and redirect after submit
Posted: 15 Feb 2018
by Nikita Kurguzov
Dear Metrovan,
Where exactly are you putting this JavaScript code? Also, can you tell me how you've published the page?