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

Sathish Nadarajan
 
Solution Architect
February 26, 2016
 
Rate this article
 
Views
10406

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.

clip_image002

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.

clip_image004

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.

 $(document).ready(function(){
     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.

Category : Infopath, SharePoint

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment