Creating a Web Link or href for SharePoint New Button on InfoPath Forms Library - Rob Haller
in

InfoPath Dev

Rob Haller

Creating a Web Link or href for SharePoint New Button on InfoPath Forms Library

Using the New button on a SharePoint InfoPath Document List is not intuitive for new SharePoint users.  It would be nice if users could simply click a web link to launch a new InfoPath Form.  Here is how to do this in a single line URL ...

Edit a Web Page and add a web link using this format:

<a href="BLOCKED SCRIPTcreateNewDocumentWithProgID(escapeProperlyCore('http://{SERVER}/{SITE}/{LIBRARY}/Forms/template.xsn', true), 'http://{SERVER}/{SITE}/{LIBRARY}/', 'SharePoint.OpenXMLDocuments', true)">Create a New Document</a>

Note: if you see the words BLOCKED SCRIPT in the line above, replace it with 'j a v a s c r i p t :' without the single quotes as shown here and without any spaces.  This blog automatically replaces the key word 'java script' (when run together) and the colon with the phrase BLOCKED SCRIPT. 

You must replace {SERVER}, {SITE}, and {LIBRARY} with your path to the forms library.  Also, you can change the phrase "Create a New Document" to whatever you want. 

I have not done this yet, but I also believe that if you have more than one form published to a library, you will need to determine what the form's name is.  The default name of "template.xsn" is used in the example above.  So, if you have more than one published form, you may need to change "template.xsn" to whatever it is called.  You can view and manage all InfoPath templates by going to the Forms Library where the form is published, then select: Settings-->Form Library Settings-->Advanced Settings.

There are posts similar to this on the web; however, none of them are as concise as this single line launcher.  Credit for this goes to my colleague, Phil Chuang.  Thanks Phil.

Comments

 

cszamir said:

Hi,

Thanks for info.  I followed your instructions above and was able to get the link to work.  However, when a user clicks on the link, it opens up the form in Infopath rather than in the browser even though I have the form Library settings 'Opening browser-enabled documents' set to: Display as a web page.  Any ideas on how to modify the link so that it opens up the new form in the browser instead of Infopath?

November 4, 2008 12:27 PM
 

Andres said:

try this url:

http://{server}/_layouts/FormServer.aspx?xsnLocation=http://{fullpath to the library}/forms/template.xsn?DefaultItemOpen=1

this should do the trick

November 5, 2008 10:15 AM
 

bmxpert1 said:

Adding onto this you can also add "&Source=http://any_url" as a parameter on the link url to tell sharepoint where to send you after closing the form. I have found this useful, hope you do too!

November 11, 2008 11:08 AM
 

Patrick Halstead said:

You may also want to read Shiraz's blog post on this:

www.infopathdev.com/.../best-way-to-launch-forms-from-web-pages.aspx

February 6, 2009 11:26 AM
 

rk1025 said:

This is great information.  However, is there a way to do this with a relative URL?   This way the function could be placed on a "development" site and when its migrated to production the code would point to the production library.  Is the only option to move away from inline javascript and then embed javascript on the page to construct the URL?  Thanks for your thoughts!

April 1, 2009 6:04 PM
 

bsuwidji said:

Is there a way to create a web link like this from inside a Form?

July 17, 2009 9:40 AM
 

warrtalon said:

Bsuwidji, create a new thread asking that so that we can all help you more easily instead of doing it through blog comments.  Just reference this blog post in your thread.

July 17, 2009 9:59 AM
 

greenawayr said:

Hi,

I'm struggling a little with this. I have the below code entered in my webpage and when the link is clicked, the screen flicks to the Infopath client and comes up with an error it doesn't normally come up with when opened. I'm looking to get the form opening up in a browser, not the client. Could someone help me with this please?

Thanks

<a href="BLOCKED SCRIPTcreateNewDocumentWithProgID(escapeProperlyCore('http://<server>/Extranet/_layouts/FormServer.aspx?XsnLocation=http://<server>/FormServerTemplates/NBSFormssharepoint.xsn&SaveLocation=http://<server>/Extranet/NBS%20Forms&Source=http://<server>/Extranet/NBS%20Forms/Forms/AllItems.aspx&DefaultItemOpen=1',true),'http://<server>/Extranet/NBS%20Forms/', 'SharePoint.OpenXMLDocuments',true)">Create a New Document</a>

October 19, 2010 8:00 AM
 

dootndo2 said:

I wanted to say thank you for posting this.  This worked great in SP 2010 Foundation.

December 8, 2011 8:12 PM
 

ghayes said:

Thanks - always wonderful to add arrows to the Quiver of Knowledge.  Unfortunately, I still seem to be missing the target on this one...

As noted by cszamir, the original code snippet opens the form in InfoPath.  That works beautifully, but I really want it to open in the web form.  I tried the suggestion from Andres, but it doesn't seem to help.  With that alteration in place, the system still tries to open the form in InfoPath, but generates an error saying "access is denied".

Any thoughts?

December 13, 2011 9:10 AM
 

ghayes said:

I should add - this is on SP 2007.

December 13, 2011 9:39 AM
 

ghayes said:

OK - Figured out most of it.  For the benefit of anyone else who hasn't tripped to the blindingly obvious, there's an easy way to determine the exact URL to open a new form in the web browser.  Open the form in the web browser using the old manual method, then cut and paste the URL that appears in the address bar of your web browser...  (a resounding chorus of "Well, DUH!!", please...)

I am left with one thing I haven't figured out yet.  Where exactly does bmxpert1's suggested "Source" parameter go?  I tried it where I though it went, and, though it produces no error, neither does it seem to have any effect.  I still end up in the document library with the form.

December 13, 2011 11:35 AM
 

ghayes said:

...and yet another link to the "Well, DUH!" file.  The link I was cuttingand pasting already HAD a "source" specifier in it, so my added source specifier was being quite properly ignored.

January 11, 2012 1:45 PM
 

rijpokh1 said:

Great Solution. Works Like a Charm. Thanks.

September 12, 2012 11:38 AM
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.