<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>SUPERNOVA &#187; Jonathan Talbot</title>
	<atom:link href="http://blog.metrostarsystems.com/author/jtalbot/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.metrostarsystems.com</link>
	<description>Stellar Social Media &#38; Technology Solutions</description>
	<lastBuildDate>Thu, 26 Apr 2012 17:31:17 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Anonymously Submit InfoPath Form to SharePoint Library</title>
		<link>http://blog.metrostarsystems.com/2009/06/04/anonymously-submit-infopath-form-to-sharepoint-library/</link>
		<comments>http://blog.metrostarsystems.com/2009/06/04/anonymously-submit-infopath-form-to-sharepoint-library/#comments</comments>
		<pubDate>Thu, 04 Jun 2009 23:37:09 +0000</pubDate>
		<dc:creator>Jonathan Talbot</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Tips & Tricks]]></category>
		<category><![CDATA[anonymous]]></category>
		<category><![CDATA[Anonymous Access]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[enterprise infrastructure]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[forms]]></category>
		<category><![CDATA[forms services]]></category>
		<category><![CDATA[infopath]]></category>
		<category><![CDATA[infopath anonymous forms]]></category>
		<category><![CDATA[Microsoft]]></category>
		<category><![CDATA[portal strategy & integration]]></category>
		<category><![CDATA[Sharepoint]]></category>
		<category><![CDATA[SharePoint 2007]]></category>
		<category><![CDATA[sharepoint library]]></category>
		<category><![CDATA[SP2007]]></category>

		<guid isPermaLink="false">http://blog.metrostarsystems.com/?p=450</guid>
		<description><![CDATA[If you’ve landed on this post, then you are probably struggling to submit InfoPath browser-enabled forms to a SharePoint library anonymously. And you’ve already learned that SharePoint doesn’t allow anonymous users to add to document and form libraries. There are some good solutions out there, but I found most to be more complex than I<em> ... </em>]]></description>
			<content:encoded><![CDATA[<p>If you’ve landed on this post, then you are probably struggling to submit InfoPath browser-enabled forms to a SharePoint library anonymously. And you’ve already learned that SharePoint doesn’t allow anonymous users to add to document and form libraries. There are some good solutions out there, but I found most to be more complex than I needed.</p>
<p>I had one anonymous access site collection. I needed anonymous users to submit a browser enabled InfoPath form, and I needed the submission to trigger a SharePoint Designer workflow. You may or may not already know this, but SharePoint Designer workflows will not trigger on items added or updated by anonymous users. <span style="color: #800000;">[Note: Prior to SP1, declarative workflows could run under System Account. If you have upgraded to SP1 then this is no longer possible. See comments below for possible solutions.] </span></p>
<p>My solution assumes you are already familiar with setting up anonymous access within MOSS 2007. If you are not, you can find information on this at <a href="http://technet.microsoft.com/en-us/library/cc263363.aspx" target="_blank">http://technet.microsoft.com/en-us/library/cc263363.aspx</a> and <a href="http://blogs.devhorizon.com/reza/?p=498" target="_blank">http://blogs.devhorizon.com/reza/?p=498</a>. You will also need to deploy your InfoPath form as an administrator-approved form template. If you are not sure how to do this, check out <a href="http://technet.microsoft.com/en-us/library/cc262921.aspx" target="_blank">http://technet.microsoft.com/en-us/library/cc262921.aspx</a> and <a href="http://www.infopathdev.com/blogs/janice/archive/2009/03/03/administrator-approved-form-templates.aspx" target="_blank">http://www.infopathdev.com/blogs/janice/archive/2009/03/03/administrator-approved-form-templates.aspx</a>. You should be able to accomplish both of the above before you proceed with this solution.</p>
<p>Below I’ll show you how to setup a SharePoint library to allow anonymous users to open your form template, and how to create a custom button to submit the form under elevated privileges.</p>
<p><strong>Enable Anonymous Access on Form Library (MOSS 2007)</strong></p>
<p>Go to Form Library Settings. Under Permissions and Management, click Permissions for this form library.</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-medium wp-image-451" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/anonform0jt20090602-300x141.png" alt="" width="270" height="127" /></td>
<td><img class="alignnone size-medium wp-image-452" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/anonform1jt20090602-300x96.png" alt="af1jt20090602" width="270" height="86" /></td>
</tr>
</tbody>
</table>
<p>Under Actions, choose Edit Permissions. When the Settings button appears, choose Anonymous Access.</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-medium wp-image-453" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/anonform2jt20090602-300x165.png" alt="" width="270" height="149" /></td>
<td><img class="alignnone size-medium wp-image-454" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/anonform3jt20090602-300x138.png" alt="" width="270" height="124" /></td>
</tr>
</tbody>
</table>
<p>You will notice that on the Change Anonymous Access Settings page only View Items is selectable. Add, Edit, and Delete Items check boxes are grayed out. As mentioned earlier, by default SharePoint only allows anonymous users to view items in document and form libraries. Without checking Add Items, anonymous users will not be able to open your browser-enabled form. To workaround this issue, look at the end of the URL for this page.</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-full wp-image-455" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/anonform4jt20090602.png" alt="" width="201" height="78" /></td>
</tr>
</tbody>
</table>
<p>Change DOCLIB to LIST and hit Enter. The page will now allow you to select Add Items for anonymous users.</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-medium wp-image-456" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/anonform5jt20090602-300x145.png" alt="" width="300" height="145" /></td>
</tr>
</tbody>
</table>
<p>Select Add Items and hit OK. While anonymous users can now open your form, when they attempt to submit the form they will receive an error. This workaround to allow anonymous access to the form template will not override SharePoint’s default policies regarding anonymous users and libraries.</p>
<p><strong>Preparing Your Administrator-Approved Form Template to Use Custom Code (InfoPath 2007)</strong></p>
<p>Open your form template in InfoPath Design mode. Under Tools, choose Form Options. In the Form Options window, choose Category: Security and Trust. You will need to set the Security Level of your form template to Full Trust.</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-full wp-image-458" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/ipanonform0jt20090602.png" alt="" width="475" height="439" /></td>
</tr>
</tbody>
</table>
<p>Next choose Category: Programming. Under Programming Language, select C# and hit OK. My solution uses C#. If you prefer to use VB or another language, there are some good conversion sites on the web. You can try the converter at <a href="http://www.developerfusion.com/tools/convert/csharp-to-vb/" target="_blank">http://www.developerfusion.com/tools/convert/csharp-to-vb/</a>. If you are already using custom VB code in your form template, then converting the C# to VB will be a must.</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-full wp-image-459" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/ipanonform1jt20090602.png" alt="" width="475" height="438" /></td>
</tr>
</tbody>
</table>
<p><strong>Adding Custom Code to Your Administrator-Approved Form Template (InfoPath 2007, Visual Studio 2005 Tools for Applications)</strong></p>
<p>You should have already setup your form template to submit to a document library under Tools: Submit Options. If you have not, you can find more info on this at <a href="http://office.microsoft.com/en-us/infopath/HA101070571033.aspx" target="_blank">http://office.microsoft.com/en-us/infopath/HA101070571033.aspx</a>.</p>
<p>Under Insert: More Controls, add a Button control to your form template. Double click your new button control, enter a unique Label and ID, and click Edit Form Code.</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-medium wp-image-460" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/ipanonform2jt20090602-300x177.png" alt="" width="300" height="177" /></td>
</tr>
</tbody>
</table>
<p>This will open your custom code in a Visual Studio environment. If you are not familiar working within Visual Studio, there are numerous primers on the web. However, this solution is straight forward and simple so you should be fine.</p>
<p>If you are developing your form template on a client operating system and not on a SharePoint development server, you will need to add a reference to Microsoft.SharePoint.dll. You can copy this dll from your SharePoint server at C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\ISAPI\. Copy the dll into your InfoPath template projects folders which will probably be located under \Documents\InfoPath Projects\.</p>
<p>After adding the dll reference, you will add the following code within your button’s click event.</p>
<table style="background-color: #ddd; border: 1px #000 dashed;" border="0" align="center">
<tbody>
<tr>
<td style="padding: 5px;"><code>SPSecurity.RunWithElevatedPrivileges(delegate()<br />
{<br />
this.Submit();<br />
});</code></td>
</tr>
</tbody>
</table>
<p>The final code should look something like this.</p>
<table border="0">
<tbody>
<tr>
<td><img class="alignnone size-full wp-image-461" src="http://blog.metrostarsystems.com/wp-content/uploads/2009/06/ipanonform3jt20090602.png" alt="" width="570" height="443" /></td>
</tr>
</tbody>
</table>
<p>Save All and Build your project. Back in InfoPath, save your template and Publish the administrator-approved form template.</p>
<p>Once the new template is published and activated to your SharePoint site collection, you should be able to open and submit the form anonymously. The form will actually submit under the System account credentials, <del datetime="2009-07-09T16:43:23+00:00">and as a bonus will successfully trigger SharePoint Designer workflows</del>. <span style="color: #800000;">[Note: As of SP1, Microsoft deprecated the ability for declarative workflows to run under System Account. See comments below for possible solutions.] </span>You will probably want to adjust some Form Options on your template to ensure that the default Submit button does not show anywhere in the user’s browser. You only want them submitting with your custom button.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.metrostarsystems.com/2009/06/04/anonymously-submit-infopath-form-to-sharepoint-library/feed/</wfw:commentRss>
		<slash:comments>27</slash:comments>
		</item>
	</channel>
</rss>

