Nov 27, 2013

InfoPath 2010 Form WebPart doesn't redirect after close

I ran into the problem where an InfoPath form displayed in an InfoPath 2010 Form WebPart wouldn't redirect to the Source URL parameter, instead simply showed an ugly "Form closed" dialog.

I found the solution here:

1. Add a content editor with the following Javascript to your page with the Form WebPart.

I've refined the JavaScript a bit from the original solution:

<script type="text/javascript">
function ClosedFormRedirect() {
  var dialogMessageElement = document.getElementById("DialogFinalMessage");
 if(dialogMessageElement != null && dialogMessageElement.children.length > 0)
    var sourceURL = GetUrlKeyValue('source', false);
    window.location.href = sourceURL;