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 :  2    Total :   5416
Plan, Migrate, Secure, Report
SharePoint & Office 365 Tool. Simple & Easy to Use. 15-Day Trial!

SharePoint Office 365 Tool
Simple & Powerful Tool for Migration, Security & Reporting. Free Trial


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.

SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Categories

Migratiin Tools for SharePoint