1

I need to retrieve an Infopath File, which is displayed and filled in on a sharepoint webpage, and save it's data to a seperate DB. There are 2 events that fire once the form is submitted. ItemAdding and ItemAdded.

I know that I can not retrieve the file from the ItemAdding Event because it only gets saved after the ItemAdding Event.

But I want to redirect users to a different website once I have stored my values to the database, but I find no way to do this. I guess, the problem is that the ItemAdded event occurs, after/or at the same time as the user gets redirected to the webpage showing "The form has been closed".

How can I retrieve the values and redirect the user? Also, I am not allowed to attach code to the infopath form itself. This needs to be handled from Sharepoint.

Thank you

Dennis G
  • 21,405
  • 19
  • 96
  • 133
Michael Frey
  • 908
  • 2
  • 14
  • 35
  • Are you using SharePoint 2010? – Shaneo Aug 19 '10 at 08:42
  • In your ItemAdded event handler, could you get your Infopath form from the event args, parse it for the data you require and then finally use SPUtility.Redirect ?? Are you sure you can't get the infopath form in memory from the event args of the ItemAdding event? – Shaneo Aug 19 '10 at 11:21
  • I have tried SPUtility.Redirect, but it does not work, because the HTTPContext is not avaliable in the event handler. I read up about ItemAdding event, and that is how i found out that the InfoPath form is added after this event. – Michael Frey Aug 20 '10 at 06:20

1 Answers1

1

If you are redirecting within the SharePoint site you can include "source" as a query string parameter.

You also try a response.redirect in the OnClose event of the infopath form.

Dennis G
  • 21,405
  • 19
  • 96
  • 133
Estyn
  • 695
  • 6
  • 9
  • Unfortunately I can not add code to the Infopath form itself, due to the requirements of the form. Could you explain what you mean with the 'source' query string parameter? – Michael Frey Aug 20 '10 at 06:28
  • 1
    http://msdn.microsoft.com/en-us/library/ms772417.aspx That link should explain it. Essentially when you close an infopath form the server will redirect to the url that is included in the source parameter. This only works if you are opening infopath so that it takes up the whole page, if you are using the infopath webpart then this won't work for you. – Estyn Aug 20 '10 at 19:29
  • We were actually planning to use a webpart, but that can be changed, so this is the closest I can get as an answer. Thanks – Michael Frey Aug 23 '10 at 07:52