SharePoint Blogs / SharePoint University
SharePoint Blogs and SharePoint University - all in one place!
Need SharePoint Training? Attend a SharePoint Bootcamp!

Please delete cookies related to sharepointblogs.com and sharepointu.com to resolve login issues!

Close New Opened Infopath form automatically

I'd a situation as subject stated. I've to close the infopath form(opened in a new window) after the form has been submited sucessfully. As aware, if it's being open in a same window, we can achive this task by mentioning "Source" element in the Url. BUT, If it's opend in a new window, no use of specifing "Source" element with Url. So, we need to do some workaround for this problem.

Here's my solution/workaround for it:-

1. Create a html page called ("WindowClose.htm)

2. Copy and paste the following code snippet and save it under "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\LAYOUTS" folder

<html>
<head>
<script language="javascript">
function closewindow() {
self.opener = this;
self.close();
}
</script>
</head>
<body onload="closewindow();">
</body>
</html>

3. Now, specify this file as source in your url. i.e.,

http://[myserver]/_layouts/FormServer.aspx?XsnLocation=/FormServerTemplates/TestForm.xsn&Source=/_layouts/windowclose.htm&DefaultItemOpen=1&PersonalInfoID=196

4. Test your application by open/submit an infopath form in a new window

In real time scenario, We've been facing this kind of issues in BDC with Infopath form. From BDC, users can search and they would like to modify the record in a new window using Infopath, user has to close the form once they done their job. To avoid these head ache, we can make use of above work around.

Hope this helps!


Posted 10-22-2007 12:57 PM by LovedJohnySmith

Comments

JL wrote re: Close New Opened Infopath form automatically
on 11-02-2007 2:22 PM

Thanks for sharing. I've been looking for a workaround to close the form after submitting. I wanted to use Form Server to submit forms without giving access to SharePoint at submitters. Closing the browser should be the default behaviour when the source parameter is missing.

JimE wrote re: Close New Opened Infopath form automatically
on 02-28-2008 10:37 PM

Not sure if it is to late to jump in here. I am a tad confused.

My goal is to have InfoPath 2007 close after submition to a MOSS form library. As it stands, the form closes just fine after submit, but InfoPath the program stays open and does not close. Clearly I want it to go back to the doc lib. Am I missing something? Any help would be appreciated.

Johnson wrote re: Close New Opened Infopath form automatically
on 03-27-2008 4:10 PM

Jim,

 Please specify your doc lib path to Source.

Thanks,

Johnson

Delia F wrote re: Close New Opened Infopath form automatically
on 05-02-2008 4:39 PM

Beautiful!  thank you so much.  This solution is clean and elegant - makes good sense.  I am sure it will do the trick for me in Designer as well.  Why CLOSE window is not an option within the Designer interface,  I'll never know.  Such a basic function!

JD wrote re: Close New Opened Infopath form automatically
on 10-10-2008 9:10 AM

Can anyone provide some step by step details. I am trying to close InfoPath after Submitting the form to the document library but since I am a rookie I do not understand what Jim ment by "Please specify your doc lib path to Source"

LC wrote re: Close New Opened Infopath form automatically
on 12-17-2008 9:54 AM

Thank you for posting this solution...works like a charm!

DR wrote re: Close New Opened Infopath form automatically
on 01-07-2009 10:40 AM

Regarding JD's post above, I'm in the same situation. Can someone help?  Thanks.

LovedJohnySmith wrote re: Close New Opened Infopath form automatically
on 01-07-2009 11:09 AM

JD & DR,

 Specify your re-direction URL path to SOURCE parameter as following...

 http://[myserver]/_layouts/FormServer.aspx?XsnLocation=/FormServerTemplates/TestForm.xsn&Source=/_layouts/windowclose.htm&DefaultItemOpen=1

Hope this helps!

Thanks,

Johnson

jayant.sharma wrote re: Close New Opened Infopath form automatically
on 01-09-2009 5:46 AM

great Post

Mike H wrote re: Close New Opened Infopath form automatically
on 04-07-2009 7:10 AM

This is an excellent post – just what I was looking for today as published InfoPath form to SharePoint doc library but as stated when submitting a new form the form closes but not InfoPath itself .  Surely Microsoft have missed as a trick here to have as one of the submit options “After Submit” to have not only – “Close Form” but also “Close Form and Close InfoPath” !!!!!

Read the code above however was like others above was unsure how to create HTML to house it and then create correct URL for this to work.  So I looked at this in a different way and would like to offer the following alternative.

I opened the Document Library where I had published my InfoPath Template and then via Site Actions – Edit Page – Add a Web Part selected Content Editor Web Part and then via Edit on this part selected Modified Shared Web Part and then in the far right of screen, in Content Editor Section clicked on Source Editor and pasted in the code as in Note 2 of the original posting – clicked on Save and then exit Edit Mode.

I then clicked on New to create via InfoPath a new input form and then clicked on Submit with close form option and was very please to see no InfoPath left open.

I hope you find this alternative of interest and support

Best regards

Mike H

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Need SharePoint Training? Attend a SharePoint Bootcamp!
Posts (c) their respective authors. Everything else (c) 2009 SharePoint Experts, Inc.