Sharepoint List redirect with new id

TheRealQuagmire picture TheRealQuagmire · Apr 29, 2009 · Viewed 19.6k times · Source

I have a list within Sharepoint, using a custom new form I have added a custom list form control ("New item form" for the list) and changed the SaveButton to a standard input HTML button, and added an 'onclick' event that is as follows:

onclick="javascript: {ddwrt:GenFireServerEvent('__commit;__redirect={NewFormWizard2.aspx?id=}')}"

This works as in saves the data and redirects to the NewFormWizard2.aspx?id= page.

How do I get the ID of the created item to be passed to the redirected page?

Thus once the form is completed it would redirect to NewFormWizard2.aspx?id=23

Answer

Eric Schrader picture Eric Schrader · Mar 19, 2010

jtherkel was close, but was missing a '}' on the end of the redirect url. I used an extra concat below

<input type="button" value="Submit" name="btnSave" onclick="javascript: {ddwrt:GenFireServerEvent(concat('__commit;__redirect={lists/MyListName/DispForm.aspx?ID=',/dsQueryResponse/Rows/Row/@ID,'}'))}" />