Tag : The form has been closed

InfoPath – Close window automatically

If you are accessing a SharePoint related InfoPath form directly through a URL in a form or an email, you may notice that when you exit from the form, a message ‘The form has been closed.’ is displayed. This is painful especially when you are accessing the form directly from a mobile device and you want the active screen to return to the calling application


After much searching online (and forgetting where I found this advice), here is a method to avoid this message

  • Create a site page in the SharePoint call CloseWindow.aspx (actually, any name could be used, but this makes it easy to understand the function of the site page)
  • Edit the page and embed the following code. Do not be surprised when the page closes automatically after you have embedded the code

<script language=”javascript” type=”text/javascript”>
    window.open(“”, “_self”);


  • In the URL that opens the page, add the following statement as a suffix to the URL that is used to access the form


  • The complete URL should look similar to the following

https://contoso.sharepoint.com/sites/Test/Lists/Attachments/Direct1.aspx?source= https://contoso.sharepoint.com/sites/Test/SitePages/CloseWindow.aspx

  • The window should now close automatically when you exit the form. Note that this may not work if the page you accessed has additional web parts defined