This project has moved and is read-only. For the latest updates, please go here.

Can I use SPRedirectWithID to redirect NewForm/EditForm to DispForm?

Oct 28, 2014 at 8:19 PM
I want to redirect NewForm/EditForm after OK or Cancel is clicked to the DispForm for the same item. Can I use SPRedirectWithID for that? Do I have to put it in each NewForm/EditForm page? Do I need any other code to make it work?
Oct 28, 2014 at 8:40 PM
You can use it in the NewForm, though I've had one report that it isn't working on 2013.

You don't need it on the EditForm because you already know the ID.

Oct 28, 2014 at 9:15 PM
It works on the NewForm, but it shows EditForm briefly before showing the DispForm (my redirectuURL).

Also, it doesn't work when I press cancel. Should it? How can I do the same with Cancel?
Oct 28, 2014 at 9:18 PM
Also, for EditForm, just write the redirectURL and leave out the qsParamName? Would this redirect to DispForm after EditForm is submitted?
<script type="text/javascript" src=""></script>
    <script type="text/javascript" language="javascript" src="//"></script>
    <script language="javascript" type="text/javascript">
    $(document).ready(function() {
            redirectUrl: "DispForm.aspx"
Oct 28, 2014 at 9:36 PM
SPRedirectWithID won't do anything on an EditForm. You already have the ID on the Query String, so just use that to build your URL.

When you use SPRedirectWithID on theNewForm, it's actually coming back to that form and waiting until the new item is actually in the list. The whole reason we need this function is that items ware written asynchronously and we don't know the ID ahead of time.

Finally, no it won't work with Cancel. You'll have to alter the behavior of that button.