Do you know if it is possible to use SPServices.SPRedirectWithID in a custom new form.

Thanks, Best regards, David


I would like to use it to redirect the user from NewForm_cst.aspx (customized version of the new form) to the EditForm.aspx.

In newform_cst i use a dataformwebpart instead of the standard listformwebpart.

In the documentation website, one user states the following:

"rdoyle78 Jan 26 at 8:12 PM Marc:

I just discovered something about SPRedirectWithID that I thought others might find useful.

I've got a list with a custom new item form, and it turns out that the SPRedirectWithID function will not work if there is not already a redirect statement applied to the 'save' button. The function works perfectly with a standard form, but it will fail if the "save" button only performs a commit - it must also have a redirect action applied. I dont' know if I just missed this in your setup, but it might be important for those of us who are using custom forms."

I guess this is my case. If think the question is how to add a redirect action and a redirect statement.

  • Weird question. In short, yes it's possible. If you want more detailed answer describe the use case. – AlexSSE Jul 7 '11 at 21:07

Your button will have a redirect if the form action takes the user to another page on commit, which is the normal case.

My suggestion is that you just try it and see if it works. If you have issues, post to the SPServices Discussions. (While I'm active here, I'll definitely see a thread on the SPServices site.) SPRedirectWithID, while not a lot if code, was a hairy function to write. I can't really cover all possible variations, of course, but it ought to work for you.

  • Thanks for the feedback. I debugged the function SPRedirectWithID, and my problem is it doesn't enter in the second cycle: As you state in the code: "If this is the load after the item is saved, wait until the new item has been saved (commits are asynchronous), // then do the redirect to redirectUrl with the new lastID, passing along the original Source. " Any idea? – David Esteves Jul 8 '11 at 18:50
  • What version of jQuery and SPServices are you using? The section of code after that comment basically loops until a new item for the current user is apparent and then redirects where you have asked. Does the code get into that while loop? – Marc D Anderson Jul 9 '11 at 2:34
  • I'm using JQuery 1.5.2 and SPServices 0.6.2. It doesn't enter in that section, which i assume it should after the user click on the save button. Maybe it's related with the dataform webpart? – David Esteves Jul 9 '11 at 18:26
  • Can you show what the Query String looks like after the commit? – Marc D Anderson Jul 9 '11 at 19:18
  • The query string looks like this after commit: ?List=0a1089a2%2D45d4%2D4e57%2D9ceb%2D229d84e86a10&RootFolder=%2Fdivisaojuridica%2Fportal%2Fpedidos%2FLists%2Fpedidos&Source=http%3A%2F%2Fdwtestes%2Eportal%2Edev%2Fdivisaojuridica%2Fportal%2Fpedidos%2FLists%2Fpedidos%2FAllItems%2Easpx (Thanks, sorry for the delay) – David Esteves Jul 11 '11 at 10:11

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.