<?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>_cyclops_'s blog &#187; Work &gt; Forms Server</title>
	<atom:link href="http://cyclops.nettrends.nl/blog/category/work-forms-server/feed/" rel="self" type="application/rss+xml" />
	<link>http://cyclops.nettrends.nl/blog</link>
	<description>Bloggin' my world....</description>
	<lastBuildDate>Sat, 21 Jan 2012 08:23:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>InfoPath (+K2): The form has been closed</title>
		<link>http://cyclops.nettrends.nl/blog/2009/02/infopath-k2-the-form-has-been-closed/</link>
		<comments>http://cyclops.nettrends.nl/blog/2009/02/infopath-k2-the-form-has-been-closed/#comments</comments>
		<pubDate>Wed, 11 Feb 2009 09:00:35 +0000</pubDate>
		<dc:creator>Ruben</dc:creator>
				<category><![CDATA[Work]]></category>
		<category><![CDATA[Work > Forms Server]]></category>
		<category><![CDATA[Work > InfoPath]]></category>
		<category><![CDATA[Work > K2.net]]></category>

		<guid isPermaLink="false">http://cyclops.nettrends.nl/blog/?p=58</guid>
		<description><![CDATA[InfoPath forms services is widely discussed product, you either love it or hate it. You mostly hate it because you would want more from the product then you can get, youâ€™re then simply running into the boundaries of InfoPath. IMHO this is a limitation of working with out of the box products. K2 BlackPearl is [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://office.microsoft.com/en-us/infopath/HA101649561033.aspx" target="_blank">InfoPath forms services</a> is widely <a href="http://www.k2distillery.com/2008/07/infopath-and-aspnet-development.html" target="_blank">discussed product</a>, you either <a href="http://blogs.technet.com/jessmeats/archive/2008/12/04/why-i-love-infopath.aspx" target="_blank">love</a> it or hate it. You mostly hate it because you would want more from the product then you can get, youâ€™re then simply running into the boundaries of InfoPath. IMHO this is a limitation of working with out of the box products.</p>
<p>K2 BlackPearl is able to integrate really well with InfoPath and is able to use InfoPath Forms Server so you donâ€™t need the full client on all the client machines. However, forms services add a few extra limitations.</p>
<p>When youâ€™re using K2 and InfoPath you can finish your K2 tasks by submitting the forms, this kicks of a web service call which helps the process move along and execute your K2 action. After it has been submit, the form will be closed, this is something the K2 integration adds (you can change it, but whatâ€™s the point). The user is then prompted with the following screen:</p>
<p><img class="aligncenter size-full wp-image-68" title="formclosed" src="http://cyclops.nettrends.nl/blog/wp-content/uploads/2009/02/formclosed.jpg" alt="formclosed" width="357" height="67" /></p>
<p>Some people think this is an error, because sometimes when <a href="http://social.technet.microsoft.com/Forums/en-US/sharepointworkflow/thread/980eef0a-80a3-4f6e-94dd-6f2b3902dd5e/" target="_self">forms server isnâ€™t able to open the form correctly</a>, this is shown. In this case itâ€™s a perfectly valid message because infopath is configured like this.</p>
<p>For the end user this isnâ€™t very user friendly and some will press the back button or close the window. The best solution is to navigate back to the K2 tasklist so the end user can pick up the next task.</p>
<h2>Getting InfoPath to go back</h2>
<p>The ones out there that have experience calling the Forms Server url from your code know that there is a <a href="http://msdn.microsoft.com/en-us/library/ms772417.aspx" target="_blank">Source querystring parameter</a>. And if your using the <a href="http://geek.hubkey.com/2007/01/infopath-forms-services-close-button_17.html" target="_black">normal sharepoint list actions you can alter those</a>.</p>
</p>
<p>To fix this in K2, you need know how K2 opens a InfoPath Client Event. And hereâ€™s a diagram of that:</p>
<p style="text-align: center;"><a href="http://cyclops.nettrends.nl/blog/wp-content/uploads/2009/02/opentaskflow.gif"><img class="aligncenter" style="border: 0pt none;" src="http://cyclops.nettrends.nl/blog/wp-content/uploads/2009/02/opentaskflow-thumb.gif" border="0" alt="OpenTaskFlow" width="538" height="96" /></a></p>
<p>The important part is in the OpenInfoPathTask.aspx, so here&#8217;s a diagram of that:</p>
<p style="text-align: center;"><a href="http://cyclops.nettrends.nl/blog/wp-content/uploads/2009/02/openinfopathtask.gif"><img class="aligncenter" style="border: 0pt none;" src="http://cyclops.nettrends.nl/blog/wp-content/uploads/2009/02/openinfopathtask-thumb.gif" border="0" alt="OpenInfoPathTask" width="487" height="271" /></a></p>
<p>The OpenInfoPathTask.aspx gets a lot of querystring parameters which are defined in the Event Item code of the InfoPath Client Event. Because the OpenInfoPathTask.aspx is in between the tasklist and the InfoPath forms services page, you do not have control over the parameters that are passed to the /_layouts/FormServer.aspx query. And, it doesn&#8217;t forward/copy the Source parameter.</p>
<h3>URL rewrite, the solution</h3>
<p>The solution to this was hard to find, but a college (<a href="http://www.brokenwire.net" target="_blank">Thijs Kroesbergen</a>) mentioned something called <a href="http://en.wikipedia.org/wiki/Rewrite_engine" target="_blank">URL Rewriting</a>. Itâ€™s pretty weird that I didnâ€™t think of it because I have used it on <a href="http://serpent.com" target="_blank">several</a> <a href="http://xceedrc.com" target="_blank">sites</a> <a href="http://www.redrc.net" target="_blank">before</a>. Even this blog uses it.</p>
<p>URL rewriting is available in <a href="http://blogs.iis.net/bills/archive/2008/05/31/urlrewrite-module-for-iis7.aspx" target="_blank">IIS7</a> but not in IIS5 or IIS6. There are 3<sup>rd</sup> party IIS ISAPI filters, we choose for the <a href="http://www.codeplex.com/IIRF" target="_blank">Ionic&#8217;s ISAPI Rewrite Filter which is available from Codeplex.com</a>. Although the configuration parameters might seem the same as <a href="http://httpd.apache.org/docs/1.3/mod/mod_rewrite.html" target="_blank">Apacheâ€™s mod_rewrite</a>, they are not! Read the readme file for the real stuff, itâ€™s a long read but is needed.</p>
<h3>Install and Configure the ISAPI filter</h3>
<p>
To install the ISAPI filter:</p>
<ul>
<li>Place the IsapiRewrite4.dll file in the c:\windows\system32\inetsrv\IIRF</li>
<li>Add an IsapiRewrite4.ini file to the same directory</li>
<li>Add read permissions for IIS_WPG to the DLL and INI file.</li>
<li>If you have logging in the INI file, add that directory and provide â€˜Everybodyâ€™ with full control (hey, make it easy on yourself J)</li>
<li>Go into Internet Information manager (winkey + R; type â€˜inetmgrâ€™)</li>
<li>Go to the properties of the web site where the InfoPath forms server is hosted (so your sharepoint site)</li>
<li>Go to the ISAPI tab</li>
<li>Add the ISAPI filter</li>
</ul>
<p>Now the INI file contains the real â€˜magicâ€™. Hereâ€™s what we used:</p>

<div class="wp_syntax"><div class="code"><pre class="ini" style="font-family:monospace;"># IsapiRewrite4.ini
#
# ini file for the ISAPI rewriter.
#
# Tue, <span style="">11</span> Jul <span style="">2006</span>Â  01:<span style="">49</span>
#
&nbsp;
RewriteLogÂ  c:\temp\iirfLog.txt
&nbsp;
RewriteLogLevel <span style="">3</span>
&nbsp;
#
# This ini file illustrates the use of a redirect rule.
# Any incoming URL that starts with an uppercase W
# will be redirected to the specified server.
&nbsp;
RewriteCond %<span style="">&#123;</span>URL<span style="">&#125;</span>   ^/_layouts/FormServer.aspx.*$
RewriteRule ^<span style="">&#40;</span>.*<span style="">&#41;</span>$     $1&amp;Source<span style="color: #000066; font-weight:bold;">=</span><span style="color: #660066;">http://gpr:1000/</span></pre></div></div>

<p>This simply adds the Source parameter to the querystring. You will <strong>NOT</strong> see this in the browser address bar, but for IIS itâ€™s there!</p>
<p>The RewriteLogLevel 3 defines a loglevel, and the RewriteLog provides the location, remember to set permissions and disable this in production.</p>
<p>The RewriteCond is a filter to apply the next line or not, so this checks if the &#8220;^/_layouts/FormServer.aspx.*$ matches the variable &#8216;URL&#8217; which is the URL, but for forms services this is without &#8216;http://domain.tld&#8217;.</p>
<p>The RewriteRule then matches the hole query and adds &amp;Source=http://gpr:1000/ to the string. The ^(.*)$ marks what&#8217;s set in $1 (everything). These are all common things within <a href="http://www.pcre.org/" target="_blank">regular expressions</a>, <a href="http://en.wikipedia.org/wiki/Regular_expression" target="_blank">hard to learn but worth it</a>.</p>
<p>Because the Source Parameter is now successfully added, the form will close and move back to a defined page (in this case, http://gpr:1000) is where the tasklist is. Please remember that the Source parameter should be filled with a <a href="http://www.sharepoint-tips.com/2007/06/solving-infopath-error-following.html" target="_blank">URL within the SAME site collection</a>.</p>
<p>And that&#8217;s it. You are now able to specify the Source parameter to the sites, it&#8217;s not dynamic (i know) but you can also redirect to some other page which handles other stuff, like close the window, just remember that this page needs to be in the same site collection!</p>
]]></content:encoded>
			<wfw:commentRss>http://cyclops.nettrends.nl/blog/2009/02/infopath-k2-the-form-has-been-closed/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

