Button link to IP forms

_IPLogo

I sometimes like to create image buttons (pasted into Content Editor Web Parts) that link to InfoPath forms. I find it makes it a bit user friendly since I can name the button how I want it to.

The only problem that I always had was when the form was updated I had to change the link to the form on all pages with the button. – and Yes, sometimes I missed one.

Here is a simple workaround to have only one source for the link.

Copy the JavaScript file to a Document Library in your SharePoint site and point to it.

Content Editor WebPart:

<script type=”text/javascript” src=”https://servername/sites/site/Scripts/BtnLink.js”></script>

<a href=”#” onclick=”openForm()”>

// Button image

<img  src=”https://servername/sites/site/SitePictures/BtnNewPurchaseRequest1.png” alt=”Click here to create new Purchase Request” /></a>

 JavaScript file (BtnLink.js):

function openForm()
{
// replacing the path will update all buttons on the SharePoint page

createNewDocumentWithRedirect(‘https:\u002f\u002fservername\u002fsites\u002fsite\
u002fPurchaseRequests\u002fforms\u002ftemplate.xsn’, ‘https:\u002f\u002fservername \u002fsites\ \u002fsite\u002fPurchaseRequests’, ‘SharePoint.OpenXmlDocuments.2′, true, ‘https://servername/sites/site/_layouts/FormServer.aspx?XsnLocation=https://servername/sites/site/PurchaseRequests/forms/template.xsn’, 0);
}

By the way, to find the link to the InfoPath form:

In Internet Explorer open the page on SharePoint that contains the document library. 

Click on ”View” – “Source” and search for “createNewDocumentWithRedirect”. This will give you something similar to the link above.  Note that you need the entire method construct. createNewDocumentWithRedirect(strTemplate, strSaveLocation, strProgID, bXMLForm, strRedirectUrl, defaultItemOpen) which makes out this awkward long link construct.

Is this Pages usefull? Usefull Useless 0 of 0 people say this Pages is usefull.