Launch an InfoPath form from a SharePoint page

Published Tuesday, August 09, 2005 5:12 PM

Here is a handy piece of sample code that can be used within a SharePoint web page as JScript that will launch an InfoPath form without using the Open/Save dialog (which sometimes causes users to download the XSN file onto their computer).  Users will still get a security prompt, which you can disable with policy if this is for intranet usage.

function LaunchInfoPath(templateURL,saveLocation)
{
//savelocation sample: "http://server/site/document library/" or "file://c:"
//templateURL sample: "http://server/site/form library/forms/template.xsn"
//The function teturns true if it worked, false if it didn't


var infopath = new ActiveXObject("SharePoint.OpenXMLDocuments.1");
var result= infopath.CreateNewDocument2(window, templateURL,saveLocation);
return result;
}

By the way, no warranty is expressed or implied here. This code is just a sample. Your mileage may vary.
Filed under:

Comments

# graham cooke said on Friday, September 21, 2007 5:46 AM

Thankyou!!

Don't suppose you have any idea how to populate a textbox on the infopath form that you have opened from the template here ???

# bhaumik said on Wednesday, July 01, 2009 4:54 PM

I want to launch infopath form without going to form library is it possible ????????

Leave a Comment

(required) 
(required) 
(optional)
(required)