SharePoint 2010 Enterprise Version

I have a Custom List and i have created a copy of NewForm.aspx and saved it as CustomNewForm.aspx. When I save the item i want to get the saved items ID and redirect the user to EditForm.aspx.

I used this article and I was able to redirect to EditForm but i'm not sure about the method used to get the Saved Item ID. http://spjsblog.com/2011/04/23/redirect-from-newform-to-dispform-or-editform/

I also tried SPServices library but its not working or the value is returned as 0. http://spservices.codeplex.com/wikipage?title=%24%28%29.SPServices.SPRedirectWithID&referringTitle=Home

  • Could you edit the first link to be more accurate. Currently it points to blog's category, which has many posts.
    – moe
    Aug 7 '14 at 12:34
  • I fixed it for you Aug 7 '14 at 12:49
  • 1
    SPRedirectWithID should have worked. If you have time, could you please post the issue you had at SPServices.codeplex.com/discussions? Aug 11 '14 at 15:50
  • Hi Marc, Sure. I'll get back to you over the weekend with some screen shots. Aug 12 '14 at 6:05

I have fixed this issue. I forgot to copy second script to edit form. Now its working as mentioned in the blog. http://spjsblog.com/2011/04/23/redirect-from-newform-to-dispform-or-editform/

1) The first script redirects to EditForm without ID

2) The second script on edit form check for ID and if its blank it retrieves the ID.

Apologies if I have wasted your time.


this function returns the Item ID from URL:

function getProjectID()
    var urlParams;
    (window.onpopstate = function () {
        var match,
            pl     = /\+/g,  // Regex for replacing addition symbol with a space
            search = /([^&=]+)=?([^&]*)/g,
            decode = function (s) { return decodeURIComponent(s.replace(pl, " ")); },
            query  = window.location.search.substring(1);

        urlParams = {};
        while (match = search.exec(query))
           urlParams[decode(match[1])] = decode(match[2]);
    return urlParams;

So I guess you can only get the ID on Edit form

  • Hi Thiago, thanks for your response but I have fixed this issue. I forgot to copy second script to edit form. Now its working as mentioned in the blog. Aug 7 '14 at 12:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.