Sladescross's Blog

Blogging about Sharepoint related stuff

Infopath Save Redirection For User Drafts April 27, 2010

Filed under: Infopath,Redirect,Save,Save Redirection — sladescross @ 10:54 am

Setting the “submit” location for InfoPath forms is easy enough. But unless we disable the “save” button, users can save the form as well. And being able to save a form before it is submitted is a good idea.

Unfortunately, the default save location is where the form is opened from. But we can alter this location in the javascript that launches the form.

You need to create some custom links that launch forms. These links call the createNewDocumentWithRedirect function. This function is called by SharePoint itself when you click the “New” button. I’ve abstracted the function so that it can be used on any site and only need to pass in the relative site path and InfoPath template we’re calling. This code can go into a content editor webpart.

Of particular interest below is the strSaveLocation variable. Setting this to ‘C:\\Documents and Settings\\All Users \\Desktop’ will save the form on the users desktop rather than the form library, but will still allow it to be submitted to the form library.

The site parameter is the relative url of the site, e.g. sites/mmr. The template parameter is the name that the form is published under. In the below case it is the Breaches and Incidents Notices form.

      function newForm(site, template){
            var url = 'http://' + window.location.hostname + '/' + site + '/';
            var template = url + template + '/Forms/template.xsn';
            var saveLocation = 'C:\\Documents and Settings\\All Users\\Desktop';
            var progID = 'SharePoint.OpenXmlDocuments.2';
            var bXMLForm = true;
            var redirectUrl = url + '_layouts/FormServer.aspx?XsnLocation=' + window.location;
            var defaultItemOpen = 0;

            createNewDocumentWithRedirect(template, saveLocation, progID, bXMLForm, redirectUrl, defaultItemOpen);
<P><A href="#">Please click here to create and submit
 a new Breach and Incident Notice.</A>
About these ads

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 63 other followers