redirecting from newform.aspx to another list

Dear Friends,

The problem i'm facing is-

When I'm at the newform.aspx page of a list (to add a new item), when I click on save button, the item should be saved in the list and then I should be redirected to another lists' newform.asxp page.

Can anyone please give me the javascript for this.

Many many thanks.

P.S- kindly note that, saving operation needs to be taken care of, before going to next lists' newform. I tried a lot but failed.

Regards,

prajK


  • Edited by Prajk11 Thursday, February 05, 2015 3:28 AM
February 5th, 2015 6:23am

Hi PrajK,

Per my understanding, you might want to redirect users to the NewForm.aspx page of another list when clicking the Save button in the NewForm.aspx page of the current list.

You can set a link like this in a view page of List1:

http://sp/Lists/List1/NewForm.aspx?Source=http://sp/Lists/List2/NewForm.aspx

Users click this link, they will be redirected to the NewForm.aspx of List1. Input data and click the Save button, they will be redirected to the NewForm.aspx of List2, at the meantime, the data input in the NewForm.aspx of List1 has been submitted properly.

Best regards
Free Windows Admin Tool Kit Click here and download it now
February 9th, 2015 2:26am

Hello Patrick,

Thanks for the answer. However I'm curious to know where to write the redirect code? Should I open the NewForm.aspx in designer to write that code? Or on dispform.aspx?

February 9th, 2015 3:20am

Hi Patrick,

Thanks for your response. 

I have used the "?source" approach already by adding it to a html button. This is one of the solution.

However what I wanted to know is- how to redirect using javascript/jQuery added in the newform.aspx page. The code that i'm using now isn't working properly. So i was wondering, if someone has got a working js for this.

Reference: http://spservices.codeplex.com/wikipage?title=%24().SPServices.SPRedirectWithID 

<script language="javascript" type="text/javascript"> $(document).ready(function() { $().SPServices.SPRedirectWithID({ redirectUrl: "EditForm.aspx", qsParamName: "OrderID" }); }); </script>

Best Regards

Free Windows Admin Tool Kit Click here and download it now
February 10th, 2015 2:27am

Hi ChandraShekhar,

You can create a button on your page, and you can use the "?source" approach. On first click it can take you to first list where you want to add your data, and then on click of submit, the "source" can take the user to the next lists' newform.aspx page and so on...

But if you would like to do it using javascript, as the former is not considered a best practice in SharePoint, then you can edit the newform.aspx page and add the redirection part in your jQuery. 

Refer these URL's for more and detailed information:

https://spservices.codeplex.com/workitem/10214

http://spservices.codeplex.com/wikipage?title=%24().SPServices.SPRedirectWithID

http://spjsblog.com/2009/09/04/redirect-from-newform-to-editform-or-custom-page/

http://sharepoint.stackexchange.com/questions/111148/get-list-item-id-from-newform-aspx

Try it out in SP2013, there is some problem with redirection. I'm not able to figure it out. Let me know if you do.

Kind Regards

February 10th, 2015 2:31am

Hi ChadraShekhar,

You can simply add Content Editor webpart in that NewForm.aspx page and inside the webpart content you can add script tag and your code, its pretty simple..

Thanks

Shakir

Free Windows Admin Tool Kit Click here and download it now
February 10th, 2015 7:10am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics