SharePoint 2013 - InfoPath WebPart – Redirect to home page after “The form has been closed” Message

Sathish Nadarajan
SharePoint MVP
Published On :   26 Feb 2016
Visit Count
Today :  1    Total :   7955

In a recent requirement, I created a Blank WebPart Page and on which, we need to add a InfoPath WebPart. The InfoPath WebPart will be available as shown in the below screen shot.


Once, added the WebPart, we need to map the Form to the WebPart. That I am leaving to the readers.

Now, the caveat here is, if the InfoPath Form within the WebPart is closed, then I want the Page to be redirected to the home page or some other page.


There is no default methods for this with the WebPart or even we cannot inject the Javascript to the InfoPath Forms directly. Hence, after some investigation, I found an interesting piece of script.

On the same page, Added a Script Editor WebPart or a Content Editor WebPart and add the below Javascript to it.

     if($('#DialogFinalMessage > div').html().length>0){
         window.location.href = "<Desired destination page URL>"

It worked like charm. After the form has been closed, this script will redirect our page to the desired destination.

Happy Coding,

Sathish Nadarajan.