Codeless SharePoint and InfoPath
Tips and tricks for the neophyte working with SharePoint Workflows and InfoPath forms
  • About This Site
  • InfoPath
  • SharePoint
  • WorkFlow
  • Contact Us
  • About This Site
  • InfoPath
  • SharePoint
  • WorkFlow
  • Contact Us
  • Home
  • /
  • InfoPath

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

105-1

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”);
    window.close();
</script>

105-2

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

?source=<SiteUrl>/SitePages/CloseWindow.aspx

  • 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
Posted on July 1, 2016 by admin. This entry was posted in InfoPath and tagged close window, infopath, sharepoint, The form has been closed. Bookmark the permalink.
InfoPath – Temporary fields in InfoPath form
Workflow – Add users to People Picker

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Powered by