in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Stef's blog

Some info about SharePoint, InfoPath, AgilePoint...

Open InfoPath form by using a link instead of navigating to the library

Having InfoPath forms in SharePoint is great, but sometimes customers complain about how to open the form.
Most likely users have to navigate in a given site to the InfoPath form library, and there click "New" in order to start-up a new form. This little piece of code makes it a lot easier by putting a link on a page.

So, what you need to do is to add a "Content Editor" webpart on the page you want to have the link displayed. Open the source editor and paste/change following snippet:
I guess you can all see what to replace in your snippet Smile. Might also be better to have a relative link instead of an abolute one, I just copied some code from the rendered HTML source of the given InfoPath form library AllItems.aspx page.

<script language="JavaScript">
   function NewAbsenceRequest()
   {
      createNewDocumentWithRedirect('http:\u002f\u002flocalhost:8040\u002fhr\u002fAbsenceRequests\u002fForms\u002ftemplate.xsn', 'http:\u002f\u002flocalhost:8040\u002fhr\u002fAbsenceRequests', 'SharePoint.OpenXmlDocuments.2', true, 'http://localhost:8040/hr/_layouts/FormServer.aspx?XsnLocation=http://localhost:8040/hr/AbsenceRequests/Forms/template.xsn', 0)
   }
</script>
<a href="BLOCKED SCRIPT NewAbsenceRequest();">New Absence Request<a>

!!! Replace the "BLOCKED SCRIPT" by "JavaScript" and a ":", this is replaced by Community Server.

Have fun!

Comments

 

Dan said:

Another simple option is to create a hyperlink to the template.xsn file it can be e-mailed to anyone with access to the SharePoint site.

yourservername.com/.../template.xsn

February 15, 2008 11:13 AM
 

ExTrEmE said:

there's a way to build the script dinamically to have a valid script in case of url domain changes (or in case of internet access to team site)?

March 19, 2008 6:51 AM
 

Daniel said:

The problem with Dan's solution is that "Save As..." doesn't attempt to save in the document library.  Therefore, form users unfamiliar with Sharepoint think they are submitting the form, but they only save it locally.

May 13, 2008 10:44 AM

Leave a Comment

(required )  
(optional )
(required )  
Add

Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts