<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://www.infopathdev.com/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Jimmy Rishe</title><link>http://www.infopathdev.com/blogs/jimmy/default.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Interacting with DBXL from code: Qdabra.Dbxl.Client</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2012/09/18/interacting-with-dbxl-from-code-qdabra-dbxl-client.aspx</link><pubDate>Mon, 17 Sep 2012 18:30:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:82740</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=82740</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2012/09/18/interacting-with-dbxl-from-code-qdabra-dbxl-client.aspx#comments</comments><description>&lt;p&gt;Occasionally, DBXL customers will ask us for assistance with interacting with DBXL from code.&amp;nbsp; Over the years, we&amp;#39;ve developed a few different utilities for using DBXL from code, and the one that we ourselves use the most often is the Qdabra.Dbxl.Client library.&lt;/p&gt;&lt;p&gt;The library can be obtained from the following download page:&lt;br /&gt;&lt;a href="http://www.infopathdev.com/files/folders/other_subjects/entry82744.aspx"&gt;http://www.infopathdev.com/files/folders/other_subjects/entry82744.aspx&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Qdabra.Dbxl.Client is a .NET library that provides a simple interface to all of DBXL&amp;#39;s web methods. Using it is quite simple.&lt;/p&gt;

&lt;p&gt;You can start off by instantiating an instance of the DbxlClient class, specifying the URL for your DBXL instance:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;DbxlClient client = new DbxlClient(&amp;quot;http://servername/QdabraWebService&amp;quot;);&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;once you&amp;#39;ve instantiated a DbxlClient instance with the above line, you can start using it to call webmethods.&amp;nbsp; A DbxlClient object has several properties, most of them corresponding to DBXL&amp;#39;s different web services.&lt;/p&gt;

&lt;p&gt;So for example, to use the Document Service&amp;#39;s GetDocument() method to retrieve a document, you could use the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;code&gt;DocumentInfo docInfo;&lt;br /&gt;StatusInfo result = client.DbxlDocumentService.GetDocument(1234, out docInfo);&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;We recommend checking the property values on the returned StatusInfo object to verify that the method call succeeded.&lt;/p&gt;

&lt;p&gt;Likewise, if you wanted to call the ReshredDocument() method in the DbxlAdmin web service, you could do the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;code&gt;StatusInfo result = client.DbxlAdmin.ReshredDocument(1234);&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That&amp;#39;s all there is to it!&lt;/p&gt;&lt;br /&gt;

&lt;p&gt;The Qdabra.Dbxl.Client library will attempt to connect to DBXL using the current user&amp;#39;s Windows Authentication credentials.&amp;nbsp; If your website uses some authentication other than Windows Authentication and it is unable to authenticate, a credential prompt will be shown prompting the user for credentials.&lt;/p&gt;

&lt;p&gt;If the user&amp;#39;s credentials are known ahead of time, they can be passed directly to the DbxlClient object by way of the Credentials parameter.&lt;/p&gt;

&lt;p&gt;It is also possible to disable the credential prompt by setting the DbxlClient object&amp;#39;s &lt;strong&gt;IsNoPromptMode&lt;/strong&gt; property to &lt;strong&gt;true&lt;/strong&gt;.&amp;nbsp; Doing so will cause the library to simply throw an exception if authentication should fail.&lt;/p&gt;&lt;br /&gt;

&lt;p&gt;So that&amp;#39;s pretty much all there is to know about Qdabra.Dbxl.Client.&amp;nbsp; How are you using code to interact with DBXL?&amp;nbsp; Let us know in the comments section.&lt;br /&gt;&lt;/p&gt;
&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=82740" width="1" height="1"&gt;</description></item><item><title>XPath Tips and Tricks:  Rounding numbers to the nearest N</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2012/08/10/xpath-tips-and-tricks-rounding-numbers-to-the-nearest-n.aspx</link><pubDate>Fri, 10 Aug 2012 06:25:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:81554</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=81554</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2012/08/10/xpath-tips-and-tricks-rounding-numbers-to-the-nearest-n.aspx#comments</comments><description>&lt;p&gt;Hello everyone,&lt;/p&gt;

&lt;p&gt;&amp;nbsp;This is the first post in (hopefully) a series of posts on handy formulas that you can use to codelessly boost your forms&amp;#39; functionality.&lt;/p&gt;

&lt;p&gt;A common question that comes up on our forums and elsewhere is: How do I round a number to the nearest [some number]?&amp;nbsp; &lt;br /&gt;XPath provides the useful round() function, but that only allows rounding to the nearest whole number.&amp;nbsp; What if you want to round to the nearest 100, or 5, or half?&lt;/p&gt;

&lt;p&gt;Luckily, round() enables us to use a simple formula to do this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;div style="color:purple;font-size:130%;"&gt;
&lt;p&gt;Round to the nearest N&lt;br /&gt;&lt;br /&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt;&amp;nbsp;div &lt;em&gt;N&lt;/em&gt;) * &lt;em&gt;N&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;br /&gt;Here, &lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt; can be a single field in your form, or an entire formula whose result you want to round.&lt;/p&gt;

&lt;p&gt;So to round to the nearest 100:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt;&amp;nbsp;div 100)&amp;nbsp;* 100&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;to round to the nearest 5:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt;&amp;nbsp;div 5)&amp;nbsp;* 5&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;to round to the nearest 1/3:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt;&amp;nbsp;div (1 div 3))&amp;nbsp;* (1 div 3)&lt;/p&gt;

&lt;p&gt;(or mathematically simplified):&lt;/p&gt;

&lt;p&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt;&amp;nbsp;* 3)&amp;nbsp;div 3&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It&amp;#39;s that simple.&lt;/p&gt;

&lt;p&gt;&lt;br /&gt;Another question that often comes up is how to round a value to N decimal places.&amp;nbsp; To do this, we can just apply the same concept:&lt;/p&gt;

&lt;blockquote&gt;
&lt;div style="color:purple;font-size:130%;"&gt;Round to N decimal places:&lt;/div&gt;

&lt;p&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt;&amp;nbsp;div 10&lt;sup&gt;-N&lt;/sup&gt;)&amp;nbsp;* 10&lt;sup&gt;-N&lt;/sup&gt;&lt;br /&gt;&lt;br /&gt;which can be simplified to:&lt;/p&gt;

&lt;div style="color:purple;font-size:130%;"&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt;&amp;nbsp;* 10&lt;sup&gt;N&lt;/sup&gt;)&amp;nbsp;div 10&lt;sup&gt;N&lt;/sup&gt;&lt;/div&gt;
&lt;/blockquote&gt;

&lt;p&gt;
So to round a value to 2 decimal places, you would use this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt; * 100)&amp;nbsp;div 100&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;to round a value to 4 decimal places:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;round(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt; * 10000) div 10000&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;&lt;br /&gt;&lt;br /&gt;As a final note, occasionally people want to round a value&amp;nbsp;&lt;strong&gt;up&lt;/strong&gt; or &lt;strong&gt;down&lt;/strong&gt; instead of to the closest number.&amp;nbsp; This is just as simple.&amp;nbsp; Simply modify the above formulas to replace &lt;strong&gt;round&lt;/strong&gt; with &lt;strong&gt;ceiling&lt;/strong&gt; to round &lt;strong&gt;up&lt;/strong&gt; or &lt;strong&gt;floor&lt;/strong&gt; to round &lt;strong&gt;down&lt;/strong&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Round up to the nearest 100&lt;/p&gt;

&lt;p&gt;ceiling(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt; div 100) * 100&lt;/p&gt;
&lt;/blockquote&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;br /&gt;Round down to the nearest 100&lt;/p&gt;

&lt;p&gt;floor(&lt;strong&gt;&lt;u&gt;value&lt;/u&gt;&lt;/strong&gt; div 100) * 100&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That&amp;#39;s it!&amp;nbsp; Enjoy!&lt;/p&gt;
&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=81554" width="1" height="1"&gt;</description></item><item><title>qRules' DecodeBase64</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2012/04/03/qrules-decodebase64.aspx</link><pubDate>Tue, 03 Apr 2012 10:26:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:77092</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=77092</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2012/04/03/qrules-decodebase64.aspx#comments</comments><description>&lt;p&gt;qRules 4.2 includes a nifty feature that allows you to immediately access the contents of text-based&amp;nbsp;files that users attach to your form.&amp;nbsp; For example, if a user attaches an ordinary text file to the form, you can extract the contents into a field bound to a textbox and immediately allow the user to edit the text, or you can just display the text in your form.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/qRules/decode64_SampleText.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;One additional feature that this new command provides is the ability to interpret the attached file as XML and add that XML to some location in&amp;nbsp;one of your form&amp;#39;s data sources.&amp;nbsp; In the below screenshot, you can see a simple example of attaching an XML file with a list of clients&amp;#39; names, which are attached to a repeating group in a secondary data source.&amp;nbsp; A textbox below also shows the extracted file text as a reference.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/qRules/decode64_XML.png" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The command&amp;#39;s syntax is as follows:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;DecodeBase64 /sourcepath=... [/sourceds=...] [/asxml=...] [/destpath=...] [/destds=...] [/excludesourceroot=...]&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Parameters surrounded with [square brackets] are optional.&amp;nbsp; Below are the uses of each of the parameters:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;b&gt;sourcepath&lt;/b&gt; - The XPath location of the file to decode.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;sourceds&lt;/b&gt; - The name of the data source where the file to decode is, if it is not in the main data source.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;asxml&lt;/b&gt; - (Boolean, &lt;b&gt;true&lt;/b&gt; by default)&amp;nbsp;When true, treats the file contents as XML and inserts it into a location in one of the form&amp;#39;s data sources.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;destpath&lt;/b&gt; - When asxml is true, the XPath location where the file&amp;#39;s XML should be inserted.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;destds&lt;/b&gt; - When asxml is true, the name of the data source where the file&amp;#39;s XML should be inserted, if not the main data source.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;excludesourceroot&lt;/b&gt; - (Boolean, &lt;b&gt;true&lt;/b&gt; by default) When true and using the&amp;nbsp;&lt;b&gt;asxml&lt;/b&gt; option,&amp;nbsp;inserts everything except the file XML&amp;#39;s root (top) node into the form&amp;#39;s data source. When false, the root node is included.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;When a file&amp;#39;s contents have been successfully extracted as text, the text contents are placed into the QdabraRules &lt;b&gt;Result&lt;/b&gt; field.&lt;/p&gt;
&lt;p style="color:blue;font-weight:bold;"&gt;&lt;i&gt;Do you have an InfoPath scenario that has a use for this command?&amp;nbsp; Let us know in the comments.&lt;/i&gt;&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=77092" width="1" height="1"&gt;</description></item><item><title>Query REST Webservices from InfoPath 2007 with qRules!</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2012/01/04/query-rest-webservices-from-infopath-2007-with-qrules.aspx</link><pubDate>Wed, 04 Jan 2012 09:04:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:73446</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=73446</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2012/01/04/query-rest-webservices-from-infopath-2007-with-qrules.aspx#comments</comments><description>&lt;p&gt;It&amp;#39;s now well known that InfoPath 2010 has the built-in ability to query REST webservices.&amp;nbsp; But did you know that you can use qRules&amp;#39; QueryData command to query REST data even if you or your users are still using InfoPath 2007?&amp;nbsp; Here&amp;#39;s a simple example of how you can do this.&lt;/p&gt;
&lt;p&gt;The below tutorial uses Yahoo&amp;#39;s Geocode API as an example of a REST webservice to look up geographical detail using a zip code.&amp;nbsp; It assumes you are working with an InfoPath form that already has qRules 2.4 or higher&amp;nbsp;injected into it.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;Open the data connection wizard to add a new data connection.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Indicate that it is a connection to &lt;strong&gt;Receive data&lt;/strong&gt; and click &lt;strong&gt;Next&lt;/strong&gt;.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Select &lt;strong&gt;XML document&lt;/strong&gt; as the source for the data and click &lt;strong&gt;Next&lt;/strong&gt;.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Enter &lt;a href="http://where.yahooapis.com/geocode?country=us&amp;amp;postal=10001"&gt;http://where.yahooapis.com/geocode?country=us&amp;amp;postal=10001&lt;/a&gt; as the location for the data.&amp;nbsp; The objective here is to provide a valid URL that will return some data from which InfoPath can detect the structure of the returned XML. Click &lt;strong&gt;Next&lt;/strong&gt;.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Select &lt;em&gt;Access the data from the specified location&lt;/em&gt; and click &lt;strong&gt;Next&lt;/strong&gt;.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Name the data source &lt;strong&gt;Zip Code Lookup&lt;/strong&gt;, uncheck &lt;em&gt;Automatically retrieve data when the form is opened&lt;/em&gt;, and click &lt;strong&gt;Finish&lt;/strong&gt;.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;You should now have a new data source with a structure that looks like this:&lt;br /&gt;&lt;img style="WIDTH:196px;HEIGHT:318px;" src="http://www.infopathdev.com/blogs/jimmy/REST/YahooDs.PNG" width="196" height="318" alt="" /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Now let&amp;#39;s add a few controls to the form.&amp;nbsp; Add a new field called &lt;strong&gt;ZipCode&lt;/strong&gt; to your main data source and create a textbox with this. Add a button underneath that and change its label to say &lt;strong&gt;Query&lt;/strong&gt;.&amp;nbsp; Also, drag the &lt;strong&gt;City&lt;/strong&gt; and &lt;strong&gt;State&lt;/strong&gt; fields from the &lt;strong&gt;Zip Code Lookup&lt;/strong&gt; data source and create textboxes or expression boxes with them.&amp;nbsp; These will display the data returned from the webservice.&amp;nbsp; Your form should look like something this when you are done:&lt;br /&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/REST/YahooQueryControls.PNG" alt="" /&gt;&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Now it&amp;#39;s time to add the query logic.&amp;nbsp; Create a new rule on the &lt;strong&gt;Query&lt;/strong&gt; button that does the following:&lt;br /&gt;&amp;nbsp;&amp;nbsp; Set the &lt;strong&gt;Command&lt;/strong&gt; field in the &lt;strong&gt;QdabraRules&lt;/strong&gt; data source to the value of the formula:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&lt;em&gt; concat(&amp;quot;QueryData /dsname=Zip Code Lookup /url=http://where.yahooapis.com/geocode?country=us&amp;amp;postal=&amp;quot;, &lt;u&gt;ZipCode&lt;/u&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &lt;img src="http://www.infopathdev.com/blogs/jimmy/REST/YahooQuery.PNG" alt="" /&gt;&lt;br /&gt;&lt;/em&gt;&lt;br /&gt;Note that this formula constructs a URL to the Yahoo webservice, concatenating in a field value from the form for the zip code.&lt;br /&gt;&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Preview the form, enter a valid zip code in the textbox and click the &lt;strong&gt;Query&lt;/strong&gt; button.&amp;nbsp; The query results should be displayed down below:&lt;br /&gt;&lt;br /&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/REST/YahooQueryResults.PNG" alt="" /&gt;&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;That&amp;#39;s it!&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=73446" width="1" height="1"&gt;</description><category domain="http://www.infopathdev.com/blogs/jimmy/archive/tags/qRules/default.aspx">qRules</category><category domain="http://www.infopathdev.com/blogs/jimmy/archive/tags/REST/default.aspx">REST</category><category domain="http://www.infopathdev.com/blogs/jimmy/archive/tags/2007/default.aspx">2007</category></item><item><title>Copying specific rows to nested repeating groups</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2011/12/21/copying-specific-rows-to-nested-repeating-groups.aspx</link><pubDate>Wed, 21 Dec 2011 08:05:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:73148</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=73148</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2011/12/21/copying-specific-rows-to-nested-repeating-groups.aspx#comments</comments><description>&lt;p&gt;A qRules customer recently came to us with a qRules task that I hadn&amp;#39;t seen before.&amp;nbsp; He had a highly nested data source divided into several sections, and he needed to copy some data from a secondary data source.&amp;nbsp;&amp;nbsp;Some of the data belonged in certain sections, and some belonged in other sections.&lt;/p&gt;
&lt;p&gt;Now that Insert&amp;#39;s /firstparentonly parameter is implemented, it would be possible to copy all of the secondary data rows into &lt;em&gt;every&lt;/em&gt; section, and then filter the view to only display the ones that belong in each section, but this isn&amp;#39;t ideal.&amp;nbsp; It bloats the main data source, which can slow down InfoPath in a multitude of ways, most significantly in the rendering of the view.&amp;nbsp; In the worst case, this can even crash InfoPath!&lt;/p&gt;
&lt;p&gt;The solution we came up with is to use a field in each section to trigger the copy operation for just that section.&amp;nbsp; We use some filtering to copy just the correct number of rows to each section and appropriately copy just the required values.&lt;/p&gt;
&lt;p&gt;A form demonstrating this technique is available here (Right-click and select &amp;quot;Save target as...&amp;quot; to download it, and then rename its extension to XSN):&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;a href="http://www.infopathdev.com/blogs/jimmy/Insert/CopyIntoNested.txt"&gt;http://www.infopathdev.com/blogs/jimmy/Insert/CopyIntoNested.txt&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;It contains a trial version of qRules.&amp;nbsp; If the functionality doesn&amp;#39;t work, please inject a newer trial or full version into it.&lt;/p&gt;
&lt;p&gt;In this particular case, each section&amp;nbsp;in the form has a &lt;strong&gt;Code&lt;/strong&gt; field that corresponds to values in the secondary data source&amp;#39;s &lt;strong&gt;Code&lt;/strong&gt; field. For each section, we want to copy the secondary rows with the same code as that section, and leave all of the others.&lt;/p&gt;
&lt;p&gt;Here are the salient details of the implementation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;CopyTrigger&lt;/strong&gt; and &lt;strong&gt;StopAction&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/CopySpecificCopyTrigger.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; Each section group has a field called &lt;strong&gt;CopyTrigger&lt;/strong&gt;, which will have rules to initiate the row copy for that particular group.&amp;nbsp; There is also a field called &lt;strong&gt;StopAction&lt;/strong&gt;, which serves as a dummy field which &lt;strong&gt;CopyTrigger&lt;/strong&gt; can use to stop itself from executing.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;CopyTrigger&lt;/strong&gt; Rules&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/CopySpecificCopyTriggerRules.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&amp;nbsp;&amp;nbsp; CopyTrigger&lt;/strong&gt; has three rules.&amp;nbsp; The idea is that CopyTrigger will execute when it is set to the value &amp;quot;go&amp;quot; and then reset itself to blank.&amp;nbsp; &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; 1. In order to stop this action from infinitely repeating, the first rule is simply a rule to stop further rules from executing when &lt;strong&gt;CopyTrigger&lt;/strong&gt; is blank.&amp;nbsp; In InfoPath 2010, every rule must have some action, so here we just give it the arbitrary action of setting the &lt;strong&gt;StopAction&lt;/strong&gt; field to blank.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/CopySpecificStopRule.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; 2. The second rule initiates an &lt;strong&gt;Insert&lt;/strong&gt; command to copy rows into the current section.&amp;nbsp; The /parent XPath is filtered to target only the section that has &lt;strong&gt;CopyTrigger&lt;/strong&gt; = &lt;strong&gt;&amp;#39;go&amp;#39;&lt;/strong&gt;, which should be only the currently executing section.&amp;nbsp; For the row count, the command uses the number of rows in the secondary data source that have the same code as the current section:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/CopySpecificCopyTriggerInsert.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; 3.&amp;nbsp;The final rule simply sets &lt;strong&gt;CopyTrigger&lt;/strong&gt; back to its initial blank value so that it can be run again if needed.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;SubChild&lt;/strong&gt; Rules&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp; &lt;strong&gt;SubChild&lt;/strong&gt;, the actual group that we will be inserting, has rules to copy the actual values into the rows being inserted.&amp;nbsp; This is a typical technique that we use for copying values using the Insert command, but it has a bit of an extra trick in that it&amp;#39;s doubly filtered, first to filter out only the source rows that have the same code as the current section, and then a second filter to select the row within those rows that is in the same position as the row currently being inserted.&amp;nbsp; This is the result:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/CopySpecificCopyValue.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Finally, we add a button that deletes all of the &lt;strong&gt;SubChild&lt;/strong&gt; groups in the form, and then sets all of the &lt;strong&gt;CopyTrigger&lt;/strong&gt; fields to &lt;em&gt;go&lt;/em&gt;, and off the operation goes!&lt;/p&gt;
&lt;p&gt;I hope this can prove useful to you if you have some need for this kind of scenario.&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=73148" width="1" height="1"&gt;</description></item><item><title>Insert's new /firstparentonly parameter</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2011/12/21/insert-s-new-firstparentonly-parameter.aspx</link><pubDate>Wed, 21 Dec 2011 06:52:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:73147</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=73147</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2011/12/21/insert-s-new-firstparentonly-parameter.aspx#comments</comments><description>&lt;p&gt;In qRules 3.4, we&amp;#39;ve added a new parameter to the Insert command that is intended to allow it to be more consistent with how people are expecting it to work.&lt;/p&gt;
&lt;p&gt;Suppose you have data source with nested repeating groups, like this:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/ParentChildDS.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;You lay them out on the form with nested repeating sections, preview the form and add a few of the parent sections, which gives you this layout:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/ParentChildParentsAdded.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Then you run the following qRules command:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Insert /parent=/my:myParentChildForm/my:Parents/my:Parent/my:Children /child=my:Child /count=3&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;A lot of people would expect this to add three &lt;strong&gt;Child&lt;/strong&gt; groups to every one of the &lt;strong&gt;Parent&lt;/strong&gt; groups, but this is not the case.&amp;nbsp; Instead, qRules only adds three &lt;strong&gt;Child&lt;/strong&gt; groups to the &lt;em&gt;first&lt;/em&gt; &lt;strong&gt;Parent&lt;/strong&gt; group, and leaves the rest alone.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/ParentChildFirstOnly.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;In order to achieve the behavior that people are expecting, we&amp;#39;ve added the &lt;strong&gt;/firstparentonly&lt;/strong&gt; parameter.&amp;nbsp; In order to maintain backwards compatibility with earlier versions, this parameter is treated as &lt;strong&gt;true&lt;/strong&gt; when it&amp;#39;s unspecified.&amp;nbsp; When it&amp;#39;s specifically specified as &lt;strong&gt;false&lt;/strong&gt;, qRules will insert groups into &lt;em&gt;all &lt;/em&gt;of the locations that match the &lt;strong&gt;/parent &lt;/strong&gt;XPath&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Insert /parent=/my:myParentChildForm/my:Parents/my:Parent/my:Children /child=my:Child /firstparentonly=false /count=3 &lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/Insert/ParentChildAllParents.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=73147" width="1" height="1"&gt;</description></item><item><title>Bulk Upload Files and Images to DBXL</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2011/08/08/bulk-upload-files-and-images-to-dbxl.aspx</link><pubDate>Sun, 07 Aug 2011 16:14:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:69048</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=69048</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2011/08/08/bulk-upload-files-and-images-to-dbxl.aspx#comments</comments><description>&lt;p&gt;A new feature has been added to the DBXL Migration Tool to allow bulk uploading files and images to DBXL.&amp;nbsp; Once these files are in DBXL, you can query them from DBXL using QueryDB, and include links to them in your XML forms.&lt;/p&gt;
&lt;p&gt;Here are the simple steps to using this feature.&amp;nbsp; These assume that you have installed a version of the Migration Tool from Aug. 4, 2011 or later.&lt;/p&gt;
&lt;p&gt;1. Open the DBXL Migration Tool from your Start Menu. &lt;/p&gt;
&lt;p&gt;2. Enter your DBXL base address (e.g. http://&lt;strong&gt;&lt;u&gt;servername&lt;/u&gt;&lt;/strong&gt;/QdabraWebService) in the &lt;strong&gt;DBXL Server Root&lt;/strong&gt; box and click Connect.&lt;/p&gt;
&lt;p&gt;3. Select the &lt;strong&gt;Custom&lt;/strong&gt; tab.&lt;/p&gt;
&lt;p&gt;4. Select &lt;strong&gt;UploadFiles.xml&lt;/strong&gt; from the &lt;strong&gt;Scenario path&lt;/strong&gt; dropdown box and click &lt;strong&gt;Connect&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/FileUpload/SelectScenario.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;5. Scroll to the bottom of the &lt;strong&gt;Scenario variables&lt;/strong&gt; pane, and in the cell for the &lt;strong&gt;filePath&lt;/strong&gt; variable, enter the full path of the folder containing the files you want to upload.&amp;nbsp; You can leave all the other variables as they are.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/FileUpload/FilePath.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;6. Click Run.&lt;/p&gt;
&lt;p&gt;7. The Migration Tool will attempt to upload each of the files in the specified folder to DBXL.&amp;nbsp; It will create and submit&amp;nbsp;a QdFile form for each file, and if the upload succeeds, it will create and submit a&amp;nbsp;QdImage form for each of these, containing the url to the QdFile attachment.&lt;/p&gt;
&lt;p&gt;8. The tool will display a log of its progress in the pane at the bottom of the tool.&amp;nbsp; If any of the files failed to upload, these will be re-listed at the end of the log.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://www.infopathdev.com/blogs/jimmy/FileUpload/UploadStatus.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Using the uploaded files&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Once the files have been uploaded to DBXL, you can have your InfoPath forms use QueryDB to query the &lt;strong&gt;QdImageDetails&lt;/strong&gt; table in the #QdabraUtility# database (you can use this alias to access the database, regardless of what its actual name is). &lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/FileUpload/QdImageCols.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;You can use QueryDB to query this table and search for files by their filename.&amp;nbsp; You can use the &lt;strong&gt;Url&lt;/strong&gt; column in the results to provide a link to any one of these files.&lt;/p&gt;
&lt;p&gt;Enjoy!&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=69048" width="1" height="1"&gt;</description></item><item><title>Using DBXL with existing data - Other approaches</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2011/07/27/using-dbxl-with-existing-data-other-approaches.aspx</link><pubDate>Wed, 27 Jul 2011 07:36:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:68764</guid><dc:creator>Jimmy</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=68764</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2011/07/27/using-dbxl-with-existing-data-other-approaches.aspx#comments</comments><description>&lt;p&gt;A while back, Hilary Stoupa wrote an excellent, detailed blog post about modifying a database table with existing data to work with a DBXL solution.&amp;nbsp; I highly recommend reading it if you are faced with that sort of situation, as it is the go-to guide for blending existing data with new data from DBXL.&amp;nbsp; Here is the link:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;COLOR:#17365d;FONT-SIZE:10pt;mso-fareast-font-family:&amp;#39;MS Gothic&amp;#39;;mso-ansi-language:EN-US;mso-fareast-language:JA;mso-bidi-language:AR-SA;mso-fareast-theme-font:minor-fareast;"&gt;&lt;a href="http://www.infopathdev.com/blogs/hilary/archive/2009/10/13/use-dbxl-submit-with-existing-sql-data.aspx"&gt;http://www.infopathdev.com/blogs/hilary/archive/2009/10/13/use-dbxl-submit-with-existing-sql-data.aspx&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;In this blog post, I would like to present a few tweaks to her design that might work a little better for some people in some cases.&amp;nbsp; The first is a modification that allows you to have a primary key on your tables and allows easily identifying which data came from your original data, and which came from DBXL.&amp;nbsp; The second tweak is a third alternative to using the trigger and stored procedure approaches Hilary described in her blog.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;An IsOriginalData field&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Suppose you have a database table with existing data that looks like the image below, and you want to be able to (a) Add data to it using DBXL and (b) Use DBXL to modify the existing data&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/ExistingData/OriginalTable.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;As in Hilary&amp;#39;s blog post, the first step would be to add a new column to store the DBXL DocId, whenever relevant&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/ExistingData/DocIdAdded.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Once you&amp;#39;ve added the DocId column, you can now add a computed column that will allow us to identify which rows are original data, and which are data from DBXL, based on whether there is a DocId present or not.&lt;br /&gt;Create a column called &lt;strong&gt;IsOriginalData&lt;/strong&gt;, and in the column&amp;#39;s properties, expand the &lt;strong&gt;Computed Column Specification&lt;/strong&gt; setting, and give it this formula:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;ISNULL(CASE WHEN DocId IS NULL THEN CAST (1 as BIT) ELSE CAST(0 as BIT) END, CAST(0 as BIT))&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://www.infopathdev.com/blogs/jimmy/ExistingData/IsOriginalDataFormula.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;The CASE statement will result in a TRUE value when DocId is null (i.e., for original data), and to FALSE when DocId is present.&amp;nbsp; There is an ISNULL function wrapped around this to ensure SQL server that the computed value for this field will always be non-null.&amp;nbsp; And the reason we want to do this is in order to be able to use this field as part of the table&amp;#39;s primary key, which requires that all of its fields be non-null.&lt;/p&gt;
&lt;p&gt;While holding the control button, select all of the columns that are currently in the table&amp;#39;s primary key, and select the IsOriginalData field as well.&amp;nbsp; Right-click any one of the, and select Set Primary Key.&amp;nbsp; This will place a primary key on all of these fields.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/ExistingData/IsOriginalAdded.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;In so doing, you will have a new primary key that is only slightly less restrictive than your current primary key.&amp;nbsp; This will allow your existing data and DBXL data to coexist for a brief moment until the trigger Hilary described in her blog post has time to run, or it will allow both to coexist long-term for the approach described in the next section.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Managing DBXL data and existing data with a view&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Hilary&amp;#39;s blog post focuses on using a trigger to remove existing data whenever data from DBXL is added, and at the end, presents an alternative approach of calling a stored procedure from InfoPath to remove existing data just before corresponding data is added to DBXL.&lt;/p&gt;
&lt;p&gt;There are people who would like to avoid using triggers in their database, and there are good reasons to avoid calling SQL directly from InfoPath (as in the case of the stored procedure approach).&lt;/p&gt;
&lt;p&gt;One third approach is to allow the old and new data to coexist in the original table, and use a database view to only expose data when it is either (a) data saved from DBXL or (b) original data that has no corresponding DBXL data.&lt;/p&gt;
&lt;p&gt;This carries the added benefit that you will have all of your original data, untouched,&amp;nbsp;in case something should go awry at any point.&lt;/p&gt;
&lt;p&gt;The steps belos assume that you have carried out the modifications in the first half of this blog post, but the approach can also be applied, with some small modifications, directly to Hilary&amp;#39;s instructions.&lt;/p&gt;
&lt;p&gt;The first step is to create a new view based off your DB table.&amp;nbsp; Right-click the Views folder in SQL Server Management Studio, select &lt;strong&gt;New View...&lt;/strong&gt;, select your table, click Add, and then close.&lt;/p&gt;
&lt;p&gt;In the designer, check the &lt;strong&gt;(All Columns)&lt;/strong&gt; box to include all columns in your view. This will create a query like the one below in the query editor:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/ExistingData/ViewStartingQuery.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Use the query editor to modify this query to make one analogous to the one below.&amp;nbsp; You should be able to make a query to fit your table by replacing &lt;strong&gt;ExistingData &lt;/strong&gt;with the name of your table, and modifying WHERE clause to match your original ID field(s) between the two aliases in the query.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/ExistingData/ExistingDataView.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;In essence, this query selects any rows in the table that (a) are from DBXL [(IsOriginalData = 0)] or (b) are original data and have no matching DBXL data (the NOT EXISTS clause).&lt;/p&gt;
&lt;p&gt;Here are the contents of my example table:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/ExistingData/ActualData.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Note that there is a row of existing data, and a row of data from DBXL with the OriginalId value &amp;quot;ABCDE.&amp;quot;&amp;nbsp; When we look at the data through the view, we can see that this row of existing data is filtered out, and everything else is displayed:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/ExistingData/ExistingDataViewData.PNG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;That&amp;#39;s it!&amp;nbsp; Enjoy!&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=68764" width="1" height="1"&gt;</description></item><item><title>WebDav Security and WebDav on IIS 6.0</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2010/06/18/webdav-security-and-webdav-on-iis-6-0.aspx</link><pubDate>Thu, 17 Jun 2010 14:33:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:55960</guid><dc:creator>Jimmy</dc:creator><slash:comments>0</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=55960</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2010/06/18/webdav-security-and-webdav-on-iis-6-0.aspx#comments</comments><description>&lt;p&gt;Last week I blogged about setting up WebDav on IIS 7.0+, so that you can take advantage of qRules&amp;#39; useful SaveToSharePoint command even if you don&amp;#39;t have SharePoint.&lt;/p&gt;
&lt;p&gt;This week, I would like to touch very briefly on the matter of security and provide some quick pointers on using WebDav on IIS 6.0, if that is what your web server is running.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;First, security.&lt;/p&gt;
&lt;p&gt;As with installing any new service on a server, there are risks to keep in mind when setting up WebDav.&amp;nbsp; WebDav, by its nature, is designed to make it easier to read and write files from and to your web server, so you naturally want to make sure only the right people are doing the right things.&amp;nbsp; Once you have gone through the simple setup steps to get SaveToSharePoint to work, it&amp;#39;s important to tighten down security to the tightest restrictions that will work for you.&lt;/p&gt;
&lt;p&gt;The following web page deals with security on WebDav.&amp;nbsp; It is geared towards IIS 6.0, but the same concepts should apply to other versions as well.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;a href="http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/4beddb35-0cba-424c-8b9b-a5832ad8e208.mspx?mfr=true"&gt;http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/4beddb35-0cba-424c-8b9b-a5832ad8e208.mspx?mfr=true&lt;/a&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Now, about using WebDav on IIS 6.0.&lt;/p&gt;
&lt;p&gt;My previous post went into a moderate amount of detail for the setup steps, because I was unable to locate a thorough tutorial for setting up WebDav on IIS 7.0 and above.&amp;nbsp; Luckily, one has already been written for IIS 6.0:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;span style="FONT-FAMILY:&amp;#39;Arial&amp;#39;,&amp;#39;sans-serif&amp;#39;;COLOR:#1f497d;FONT-SIZE:10pt;mso-fareast-font-family:&amp;#39;MS PGothic&amp;#39;;mso-ansi-language:EN-US;mso-fareast-language:JA;mso-bidi-language:AR-SA;"&gt;&lt;a href="http://www.windowsnetworking.com/articles_tutorials/WebDAV-IIS.html"&gt;&lt;font color="#0000ff"&gt;http://www.windowsnetworking.com/articles_tutorials/WebDAV-IIS.html&lt;/font&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Once you have installed WebDav on your server, create a virtual directory for your files, similarly to the way I described in my earlier blog post.&amp;nbsp;&amp;nbsp; In the &lt;strong&gt;Virtual Directory&lt;/strong&gt; tab of the virtual folder&amp;#39;s properties, just enable Read, Write, and (if desired) Directory browsing.&amp;nbsp; Click ok to save the changes, and you should be all set to test out the feature.&lt;/p&gt;
&lt;p&gt;&lt;img style="WIDTH:461px;HEIGHT:440px;" title="Virtual Folder Properties" alt="Virtual Folder Properties" src="http://www.infopathdev.com/blogs/jimmy/misc/folderPropertiesRWB.png" width="461" height="440" /&gt;&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=55960" width="1" height="1"&gt;</description></item><item><title>Saving Forms as New to DBXL</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2010/06/16/saving-forms-as-new-to-dbxl.aspx</link><pubDate>Wed, 16 Jun 2010 06:10:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:55904</guid><dc:creator>Jimmy</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=55904</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2010/06/16/saving-forms-as-new-to-dbxl.aspx#comments</comments><description>&lt;p&gt;Typically when you open a form from DBXL and re-submit it, your modified form will be saved on top of the one you opened.&amp;nbsp; This is a very useful feature, and undoubtedly what you want to do most of the time, but sometimes you will want to save a new copy of a form and leave the original one unchanged.&amp;nbsp; This short tutorial will teach you how to do that.&lt;a title="_GoBack" name="_GoBack"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;The DBXL PI&lt;/h2&gt;
&lt;p&gt;When you open a form from DBXL, the form&amp;#39;s XML will have an XML Processing Instruction (PI) embedded in it.&amp;nbsp; This PI contains the form&amp;#39;s DocId, and some other information, and when you re-submit the form, DBXL reads this and knows which form to overwrite.&lt;/p&gt;
&lt;p&gt;Therefore, if you remove this PI, DBXL will treat the form as a new document, and will save it as a new form, instead of overwriting the original.&amp;nbsp; Below are two methods for removing this PI.&lt;/p&gt;
&lt;h3&gt;Using qRules&lt;/h3&gt;
&lt;p&gt;qRules includes a command to remove the DBXL PI from an XML form. Just use this simple command:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; RemoveDbxlPi&lt;/p&gt;
&lt;h3&gt;Using Code&lt;/h3&gt;
&lt;p&gt;If you would prefer to use code, you can use the following short snippet to locate the DBXL PI, and remove it if it is present:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;const string piXPath = &amp;quot;/processing-instruction()[name() = &amp;#39;QdabraDBXL&amp;#39;]&amp;quot;;&lt;br /&gt;XPathNavigator pi = MainDataSource.CreateNavigator().SelectSingleNode(piXPath);&lt;/p&gt;
&lt;p&gt;if (pi != null)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; pi.DeleteSelf();&lt;br /&gt;}&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Once you have used one of the two above methods, your form should be submitted as a new document the next time you submit it.&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=55904" width="1" height="1"&gt;</description></item><item><title>Using qRules' SaveToSharePoint Command Without SharePoint</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2010/06/04/using-qrules-savetosharepoint-command-without-sharepoint.aspx</link><pubDate>Fri, 04 Jun 2010 14:19:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:55622</guid><dc:creator>Jimmy</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=55622</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2010/06/04/using-qrules-savetosharepoint-command-without-sharepoint.aspx#comments</comments><description>&lt;p&gt;qRules provides a handy command called SaveToSharePoint, that allows you to save attachments in your InfoPath forms to a SharePoint server, to reduce the size of your XML forms, and allow these files to be accessed without opening up your forms in InfoPath.&lt;/p&gt;
&lt;p&gt;But in spite of its name, you don&amp;#39;t have to have SharePoint to take advantage of this command. Using a module called WebDAV, it&amp;#39;s possible to configure an ordinary IIS website to allow files to be saved to it.&amp;nbsp; This tutorial goes through a few simple steps for setting up WebDAV, to accept files saved via the SaveToSharePoint command.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;This tutorial assumes the three following requirements:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;You will be saving the files to a server running Windows Vista, Windows Server 2008, or Windows 7&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;You already have an IIS website running on your server&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Your website uses Windows authentication&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;Without further ado, here&amp;#39;s how to set up a file repository where you can save your files.&lt;/p&gt;
&lt;p&gt;1.&amp;nbsp; Ensure you have WebDAV installed on your server.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Open up IIS manager, and in the Connections pane, expand the Sites folder and click the node for your website.&lt;/p&gt;
&lt;p&gt;A number of icons should be shown in the center of IIS Manager.&amp;nbsp; Look in the &lt;strong&gt;IIS&lt;/strong&gt; section of this group of icons and look for an icon called &lt;strong&gt;WebDAV Authoring Rules&lt;/strong&gt;.&amp;nbsp; If this icon is present, please skip to Step 2.&lt;/p&gt;
&lt;p&gt;If you see no &lt;strong&gt;WebDAV Authoring Rules&lt;/strong&gt; icon, you will need to install or enable WebDAV.&amp;nbsp; Please consult the corresponding &lt;strong&gt;Installing WebDAV&lt;/strong&gt; section of the following page to get WebDAV setup on your server.&amp;nbsp; Vista and Windows Server 2008 users should consult the section for IIS 7.0.&amp;nbsp; Windows 7 users should consult the section for IIS 7.5.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://learn.iis.net/page.aspx/350/installing-and-configuring-webdav-on-iis-7/"&gt;http://learn.iis.net/page.aspx/350/installing-and-configuring-webdav-on-iis-7/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Once you have installed WebDAV, please close and reopen IIS manager, and ensure that the &lt;strong&gt;WebDAV Authoring Rules&lt;/strong&gt; icon is available now.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;2.&amp;nbsp; Create a virtual folder for your saved files.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Since you don&amp;#39;t want to allow users to save files just anywhere on your site, the next step is to create a virtual folder where files can be saved to your site.&amp;nbsp; Right-click your site&amp;#39;s node in the &lt;strong&gt;Connections&lt;/strong&gt; pane, and select &lt;strong&gt;Add Virtual Directory...&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Give the virtual directory a name (this is the subdirectory of your site where files will be saved), and create and/or select a physical folder on the hard disk to which this folder will correspond.&amp;nbsp; Click OK.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;3.&amp;nbsp; Enable WebDAV on the new virtual folder.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Select your site again in the &lt;strong&gt;Connections&lt;/strong&gt; pane, and double-click the &lt;strong&gt;WebDAV Authoring Rules&lt;/strong&gt;&amp;nbsp;icon.&amp;nbsp; Click the &lt;strong&gt;Enable WebDAV&lt;/strong&gt; text in the &lt;strong&gt;Actions&lt;/strong&gt; pane to the right to enable WebDAV for the site.&lt;/p&gt;
&lt;p&gt;Now, select your new virtual folder in the &lt;strong&gt;Connections&lt;/strong&gt; pane so that the top of the center pane says &lt;strong&gt;&lt;em&gt;FolderName &lt;/em&gt;Home&lt;/strong&gt;, where&amp;nbsp;&lt;em&gt;FolderName&lt;/em&gt; is the name of your new folder.&lt;/p&gt;
&lt;p&gt;Double-click&amp;nbsp;the &lt;strong&gt;WebDAV Authoring Rules&lt;/strong&gt; icon again.&amp;nbsp; Now click the &lt;strong&gt;Add Authoring Rule...&lt;/strong&gt; text in the &lt;strong&gt;Actions&lt;/strong&gt; pane to create a rule to allow saving and accessing files in this virtual directory.&amp;nbsp; For simplicity, just add a simple rule that allows Read, Write, and Source, for all content and all users.&amp;nbsp; Click OK.&amp;nbsp; You have now set up your virtual directory to use WebDAV.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;4.&amp;nbsp; Set up an index for your virtual folder.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;One last step to allowing SaveToSharePoint to work on your site is to set up an index for your new virtual directory.&amp;nbsp; By default, IIS prevents making requests directly to folders on a site, and this will cause SaveToSharePoint to not work.&amp;nbsp; You have options.&lt;/p&gt;
&lt;p&gt;a.&amp;nbsp; If you would like users to be able to see a list of the files in the folder using a browser&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Again select your new virtual folder in the &lt;strong&gt;Connections&lt;/strong&gt; pane of IIS Manager.&lt;/p&gt;
&lt;p&gt;Double click the &lt;strong&gt;Directory Browsing&lt;/strong&gt; icon in the &lt;strong&gt;IIS&lt;/strong&gt; section of the central pane.&lt;/p&gt;
&lt;p&gt;Click the &lt;strong&gt;Enable&lt;/strong&gt; text in the &lt;strong&gt;Actions&lt;/strong&gt; pane.&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;b.&amp;nbsp; If you do &lt;u&gt;not&lt;/u&gt; want users to see a list of the files in the folder&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Open a new instance of Notepad&lt;/p&gt;
&lt;p&gt;Without entering any text, save the file with the name &lt;strong&gt;index.htm&lt;/strong&gt; in the physical disk location that corresponds to your virtual directory&lt;/p&gt;
&lt;p&gt;This will cause a blank page to be displayed if anyone navigates to this directory in a browser.&amp;nbsp; If you like, you can instead use a file with HTML, to display a certain page to users who navigate to that directory.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;&lt;/blockquote&gt;
&lt;p&gt;If the above went successfully, you should now be able to use the SaveToSharePoint qRules command to save InfoPath attachments to your site.&amp;nbsp; Just specify the URL to your virtual folder in the command&amp;#39;s &lt;em&gt;url&lt;/em&gt; parameter:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;SaveToSharePoint /url=http://&lt;strong&gt;&lt;em&gt;intranet.site&lt;/em&gt;&lt;/strong&gt;/&lt;strong&gt;&lt;em&gt;InfoPathSaveFiles&lt;/em&gt;&lt;/strong&gt;/ /xpath=/my:myFields/my:files/my:file&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;Best of luck!&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=55622" width="1" height="1"&gt;</description></item><item><title>A mutually exclusive radio button in a repeating section</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2009/08/05/a-mutually-exclusive-radio-button-in-a-repeating-section.aspx</link><pubDate>Wed, 05 Aug 2009 01:51:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:45419</guid><dc:creator>Jimmy</dc:creator><slash:comments>2</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=45419</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2009/08/05/a-mutually-exclusive-radio-button-in-a-repeating-section.aspx#comments</comments><description>&lt;p&gt;Here&amp;#39;s a nifty trick you can use when you want to add a radio button or checkbox to a repeating section or table that can only be checked in one row of the section or table at any given time.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The Scenario&lt;br /&gt;&lt;/strong&gt;You are creating a form for a team roster for teams in a sports tournament.&amp;nbsp; As a rule, each team may only designate one team captain and one vice-captain.&amp;nbsp; You could enforce this using custom validation, but let&amp;#39;s see if we can&amp;#39;t do something a bit fancier.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Creating the form&lt;br /&gt;&lt;/strong&gt;We begin by dragging an empty repeating section into the form:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/exclusiveCheck/emptyRepeating.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;By default, this section will be created as &lt;strong&gt;my:group2&lt;/strong&gt;.&lt;br /&gt;We then add the fields that we want below &lt;strong&gt;my:group2&lt;/strong&gt;.&amp;nbsp; We create a &lt;strong&gt;my:name&lt;/strong&gt; field to store each team member&amp;#39;s name (this will not serve a real purpose in this demo, but let&amp;#39;s include it for good measure), a &lt;strong&gt;my:captain&lt;/strong&gt; field and a &lt;strong&gt;my:vice-captain&lt;/strong&gt; field (let&amp;#39;s create both of these fields as Boolean (true/false) fields.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/exclusiveCheck/dataSource.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Then we drag the fields into the repeating section from the taskpane.&amp;nbsp; First we drag the name field in and create it as a text box.&amp;nbsp; Then we drag the &lt;strong&gt;captain&lt;/strong&gt; field &lt;strong&gt;&lt;em&gt;with the right mouse button&lt;/em&gt;&lt;/strong&gt; and create it as a checkbox, and drag the &lt;strong&gt;vice-captain&lt;/strong&gt; field with the right mouse button and create it as a radio (option) button.&amp;nbsp; (Ordinarily you would probably just use one or the other, but for the sake of demonstration we&amp;#39;ll use one of each this time.&lt;br /&gt;Creating the radio button should create a checked and unchecked radio button with the words Yes and No next to them.&amp;nbsp; Delete the No radio button and change the &amp;quot;Yes&amp;quot; text to &amp;quot;Vice-captain.&amp;quot;&lt;/p&gt;
&lt;p&gt;The final result should look like this:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/exclusiveCheck/fullLayout.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Adding rules&lt;br /&gt;&lt;/strong&gt;Now that everything&amp;#39;s laid out, it&amp;#39;s time to add rules to make the fields mutually exclusive.&amp;nbsp; Right-click the checkbox (the captain field)&amp;nbsp;and select Rules... top open up the Rules dialog box, and then click Add... to add a new rule, and name it &amp;quot;Clear other captains&amp;quot;.&lt;br /&gt;Click Set condition... to create a condition and set the condition to be &lt;em&gt;&lt;strong&gt;captain&lt;/strong&gt; is equal to TRUE.&lt;/em&gt; That is, whenever a user clicks this checkbox to designate a team member as the captain, we want the rule to clear all of the other &lt;strong&gt;captain&lt;/strong&gt; fields.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img src="http://www.infopathdev.com/blogs/jimmy/exclusiveCheck/whenTrue.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Now add the rule action.&amp;nbsp; Make the action &amp;quot;Set a field&amp;#39;s value.&amp;quot;&amp;nbsp; Select the &lt;strong&gt;captain&lt;/strong&gt; field itself as the field to set, and for the value, just type &lt;strong&gt;false&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/exclusiveCheck/clearRule.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Please repeat this process for the vice-captain field, replacing &lt;strong&gt;captain&lt;/strong&gt; with &lt;strong&gt;vice-captain&lt;/strong&gt; in the instructions above.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Not done yet&lt;/strong&gt;&lt;br /&gt;If you preview the form at this point, you will find that you are unable to check any of the checkboxes or radio buttons. This is to be expected.&amp;nbsp; As soon as you try to set a value to TRUE, the rule is setting all of the nodes of that field to false, &lt;em&gt;including the field you just checked&lt;/em&gt;.&amp;nbsp; To get around this, we&amp;#39;ll need to employ a little trick that Hilary Stoupa blogged &lt;a href="http://www.infopathdev.com/blogs/42575.aspx"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Editing the manifest&lt;/strong&gt;&lt;br /&gt;Save the form as its source files, close InfoPath and locate the place where you saved the files.&amp;nbsp; Open the manifest.xsf file in a text editor of your choice.&lt;/p&gt;
&lt;p&gt;In the xsf:ruleSets section, you should find the definitions for your rules:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/exclusiveCheck/rulesBeforeEdit.JPG" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;For the first rule, edit the targetField attribute to have the value:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;(../preceding-sibling::my:group2 | ../following-sibling::my:group2)/my:captain&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This will tell InfoPath to set the &amp;quot;false&amp;quot; value to the my:captain field in all preceding and following repeating nodes.&lt;/p&gt;
&lt;p&gt;Now do the same for the vice-captain rule, replacing my:captain with my:vice-captain.&lt;/p&gt;
&lt;p&gt;Save the manifest.xsf file, right-click it in Internet Explorer and click Design to open it up in Design mode again.&lt;/p&gt;
&lt;p&gt;Now preview the form.&amp;nbsp; If you&amp;#39;ve done everything right up to this point, you should find that any time you click a captain checkbox, all of the other captain checkboxes become cleared, and the same happens for the vice-captain radio buttons.&lt;/p&gt;
&lt;p&gt;&lt;img style="WIDTH:518px;HEIGHT:307px;" src="http://www.infopathdev.com/blogs/jimmy/exclusiveCheck/allDone.JPG" width="518" height="307" alt="" /&gt;&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=45419" width="1" height="1"&gt;</description></item><item><title>Executing a stored procedure with OUTPUT parameters</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2009/08/01/executing-a-stored-procedure-with-output-parameters.aspx</link><pubDate>Sat, 01 Aug 2009 01:09:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:45305</guid><dc:creator>Jimmy</dc:creator><slash:comments>4</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=45305</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2009/08/01/executing-a-stored-procedure-with-output-parameters.aspx#comments</comments><description>&lt;p&gt;Many people are aware that you can use InfoPath code or script to perform all sorts of database queries on tables, views, stored procedures and the like.&amp;nbsp; I won&amp;#39;t go into the details here, but you can read more about this at the following links:&lt;/p&gt;
&lt;p style="MARGIN-LEFT:40px;"&gt;&lt;a href="http://www.infopathdev.com/forums/p/8940/31780.aspx#31780"&gt;http://www.infopathdev.com/forums/p/9467/33496.aspx#33496&lt;br /&gt;http://www.infopathdev.com/forums/p/8940/31780.aspx#31780&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;But what happens when you want to query a stored procedure that uses OUTPUT parameters?&amp;nbsp; I ran into this issue while helping a forum poster in this thread:&lt;/p&gt;
&lt;p style="MARGIN-LEFT:40px;"&gt;&lt;a href="http://www.infopathdev.com/forums/t/12506.aspx"&gt;http://www.infopathdev.com/forums/t/12506.aspx &lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;Suppose I have this elementary stored procedure, which returns the square and half of the input value:&lt;/p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;
&lt;blockquote&gt;
&lt;p&gt;CREATE&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;PROCEDURE&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; [dbo]&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;.&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;[SimpleStoredProcedure]&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; @inputValue &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font size="2"&gt;@inputSquared &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;bigint&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;output&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;@inputHalved &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;output&lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SET&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;NOCOUNT&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;ON&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;SET&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; @inputSquared &lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#ff00ff" size="2"&gt;&lt;font color="#ff00ff" size="2"&gt;CAST&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;@inputValue &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;bigint&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;)&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;*&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#ff00ff" size="2"&gt;&lt;font color="#ff00ff" size="2"&gt;CAST&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;(&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;@inputValue &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;AS&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;bigint&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;SET&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; @inputHalved &lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;=&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; @inputValue &lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;/&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 2&lt;br /&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;font color="#008000" size="2"&gt;&lt;font color="#008000" size="2"&gt;-- return some value just for the heck of it&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/font&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;return&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; 7&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;END&lt;/p&gt;&lt;/blockquote&gt;&lt;/font&gt;&lt;/font&gt;
&lt;p&gt;If I try to execute this procedure from InfoPath code like this&amp;nbsp;(C# 2007 here):&lt;/p&gt;&lt;font size="2"&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;AdoQueryConnection&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; conn = DataConnections[&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;TestDatabase&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;] &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;as&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; &lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;AdoQueryConnection&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; originalCommand = conn.Command;&lt;br /&gt;&lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;string&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; query = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;EXECUTE SimpleStoredProcedure 23&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&amp;nbsp; // just pass in 23 as an arbitrary value&lt;br /&gt;conn.Command = query;&lt;br /&gt;conn.Execute();&lt;br /&gt;conn.Command = originalCommand;&lt;br /&gt;RunQuery(query);&lt;/font&gt;&amp;nbsp;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;I get this error:&lt;/p&gt;
&lt;p&gt;The query cannot be run for the following DataObject: TestDatabase&lt;br /&gt;InfoPath cannot run the specified query.&lt;br /&gt;[0x80040E10][Microsoft OLE DB Provider for SQL Server] Procedure or function &amp;#39;SimpleStoredProcedure&amp;#39; expects parameter &amp;#39;@inputSquared&amp;#39;, which was not supplied.&lt;/p&gt;
&lt;p&gt;this is because my query does not give the stored procedure any place to store the values of its output parameters.&amp;nbsp; What&amp;#39;s more, I have no way of accessing these parameters because by default, InfoPath only receives the value of the &lt;strong&gt;return&lt;/strong&gt; statement from a stored procedure, which would always be &lt;strong&gt;7&lt;/strong&gt; in this case.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;The solution:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The thing to remember here is that you don&amp;#39;t have to limit yourself to having just one SQL statement in your query.&amp;nbsp; You can have several.&amp;nbsp; And that&amp;#39;s just what we need here.&lt;/p&gt;
&lt;p&gt;What we can do is have the query create some SQL variables to hold the output parameters, and then SELECT them so that their values get sent back to InfoPath.&amp;nbsp; First we create the SQL variables and pass them into the stored procedure:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;DECLARE&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; @squareOutput &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;bigint&lt;/font&gt;&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; @halfOutput &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;int&lt;br /&gt;EXECUTE &lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;SimpleStoredProcedure 23&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; @squareOutput OUTPUT&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; @halfOutput OUTPUT&lt;/p&gt;&lt;/font&gt;&lt;/blockquote&gt;
&lt;p&gt;We can do this by modifying the third line of my code above to:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;nbsp;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font size="2"&gt; query = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;DECLARE @squareOutput bigint, @halfOutput int &amp;quot; + &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;EXECUTE SimpleStoredProcedure 23, @squareOutput OUTPUT, @halfOutput OUTPUT&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;;&lt;br /&gt;[GOTCHA: Don&amp;#39;t forget the space at the end of the first line of the statement or you will wind up with something like &lt;strong&gt;intEXECUTE&lt;/strong&gt; in your statement]&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;This is still incomplete because no values come back from the query, and the secondary data source&amp;#39;s contents look like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&amp;lt;dfs:myFields xmlns:dfs=&amp;quot;http://schemas.microsoft.com/office/infopath/2003/dataFormSolution&amp;quot;/&amp;gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;To finish this solution off, we need to SELECT the value of the SQL variables so that they will be sent back to InfoPath, like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font color="#0000ff" size="2"&gt;SELECT&lt;/font&gt; @squareOutput &lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;AS&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; SquareOut&lt;/font&gt;&lt;font color="#808080" size="2"&gt;&lt;font color="#808080" size="2"&gt;,&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; @halfOutput &lt;/font&gt;&lt;font color="#0000ff" size="2"&gt;&lt;font color="#0000ff" size="2"&gt;AS&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt; HalfOut&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;I&amp;#39;ve specified aliases (SquareOut and HalfOut) for the SELECT column names because otherwise they will come back without names and InfoPath will give them meaningless names like &lt;strong&gt;c0&lt;/strong&gt; and &lt;strong&gt;c1&lt;/strong&gt;.&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;The code looks like this at this point:&lt;/font&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&lt;font color="#0000ff"&gt;string&lt;/font&gt;&lt;font size="2"&gt; query = &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;DECLARE @squareOutput bigint, @halfOutput int &amp;quot; + &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;EXECUTE SimpleStoredProcedure 23, @squareOutput OUTPUT, @halfOutput OUTPUT&amp;nbsp;&amp;quot; +&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;quot;SELECT @squareOutput AS SquareOut, @halfOutput AS HalfOut&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;;&lt;br /&gt;[Again, don&amp;#39;t forget the space at the end of the second line of the statement]&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;Finally, we run the query, and we get back our result, with our requested values:&lt;/font&gt;&lt;/font&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;&amp;lt;dfs:myFields xmlns:dfs=&amp;quot;http://schemas.microsoft.com/office/infopath/2003/dataFormSolution&amp;quot;&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;dfs:dataFields&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;d:row xmlns:d=&amp;quot;http://schemas.microsoft.com/office/infopath/2003/ado/dataFields&amp;quot; &lt;strong&gt;&lt;em&gt;HalfOut=&amp;quot;529&amp;quot; SquareOut=&amp;quot;11&amp;quot;&lt;/em&gt;&lt;/strong&gt;/&amp;gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/dfs:dataFields&amp;gt;&lt;br /&gt;&amp;lt;/dfs:myFields&amp;gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=45305" width="1" height="1"&gt;</description></item><item><title>Programmatically adding rows to repeating sections</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2009/03/06/automatically-adding-rows-to-repeating-sections.aspx</link><pubDate>Fri, 06 Mar 2009 06:48:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:39265</guid><dc:creator>Jimmy</dc:creator><slash:comments>6</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=39265</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2009/03/06/automatically-adding-rows-to-repeating-sections.aspx#comments</comments><description>&lt;p&gt;Users on the InfoPathDev forum frequently ask how they can add rows to repeating groups from code.&amp;nbsp; There is a relatively simple way to do this, but it has a few limitations.&amp;nbsp; I may write another blog post later that describes a more general approach that is trickier but does not have these limitations, but for now, this option is available for forms that meet the following criteria:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div&gt;The form must not be browser-enabled.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The repeating group must be represented in a repeating section or repeating table in the form.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The view containing the repeating section/table must be the currently displayed view when the row is added.&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The repeating group must not be &lt;i&gt;inside&lt;/i&gt; another repeating group, or be recursive.&lt;/div&gt;&lt;/li&gt;&lt;/ul&gt;
&lt;p&gt;If your form meets all of these requirements, please read on.&lt;/p&gt;
&lt;p style="FONT-SIZE:14pt;"&gt;&lt;b&gt;XmlToEdit&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Before proceeding, you must understand a bit about the XmlToEdit value.&amp;nbsp; Certain controls (including repeating sections and tables) have&amp;nbsp;a property called XmlToEdit, which has a unique value for each different control.&amp;nbsp; You can find this value with the following steps:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;Right-click the control (you can click the little tab at the bottom-left corner of the repeating section or table)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Select &lt;b&gt;Repeating Table Properties...&lt;/b&gt; or &lt;b&gt;Repeating Section Properties...&lt;/b&gt; (at the bottom of the context menu)&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;Click the Advanced tab.&amp;nbsp; The XmlToEdit value should be displayed towards the bottom of the dialog box.&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;Throughout this blog post I will be using the text &lt;b&gt;&lt;i&gt;XmlToEdit&lt;/i&gt;&lt;/b&gt; as a placeholder for this value.&amp;nbsp; &lt;b&gt;&lt;span style="COLOR:red;"&gt;Make sure to replace this text with the actual XmlToEdit value of your control.&lt;/span&gt;&lt;/b&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;With that out of the way, let&amp;#39;s look at the actual code.&amp;nbsp; It is a single line in all six language models that InfoPath supports and I will show you that code for each language.&lt;/p&gt;
&lt;p&gt;&lt;b&gt;C# 2007&lt;/b&gt;&lt;/p&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;blockquote&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;CurrentView.ExecuteAction(&lt;/font&gt;&lt;font color="#2b91af" size="2"&gt;&lt;font color="#2b91af" size="2"&gt;ActionType&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;.XCollectionInsert, &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;&lt;i&gt;&lt;b&gt;XmlToEdit&lt;/b&gt;&lt;/i&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;b&gt;Visual Basic 2007&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;blockquote&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;CurrentView.ExecuteAction(ActionType.XCollectionInsert, &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;&lt;b&gt;&lt;i&gt;XmlToEdit&lt;/i&gt;&lt;/b&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;b&gt;C# 2003&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;blockquote&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;thisXDocument.View.ExecuteAction(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;xCollection::insert&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;&lt;b&gt;&lt;i&gt;XmlToEdit&lt;/i&gt;&lt;/b&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;);&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;b&gt;Visual Basic 2003&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;&lt;font size="2"&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;blockquote&gt;&lt;font size="2"&gt;
&lt;/font&gt;&lt;p&gt;&lt;font size="2"&gt;thisXDocument.View.ExecuteAction(&lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;xCollection::insert&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, &lt;/font&gt;&lt;font color="#a31515" size="2"&gt;&lt;font color="#a31515" size="2"&gt;&amp;quot;&lt;b&gt;&lt;i&gt;XmlToEdit&lt;/i&gt;&lt;/b&gt;&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;)&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;b&gt;JScript&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;XDocument.View.ExecuteAction(&amp;quot;xCollection::insert&amp;quot;, &amp;quot;&lt;b&gt;&lt;i&gt;XmlToEdit&lt;/i&gt;&lt;/b&gt;&amp;quot;); &lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;b&gt;VBScript&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;XDocument.View.ExecuteAction &amp;quot;xCollection::insert&amp;quot;, &amp;quot;&lt;b&gt;&lt;i&gt;XmlToEdit&lt;/i&gt;&lt;/b&gt;&amp;quot; &lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&lt;b&gt;qRules 1.5&lt;/b&gt; (codeless forms)&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Forms with qRules 1.5 (free trial on Qdabra.com&lt;span class=""&gt;&lt;/span&gt;)&amp;nbsp;can also use a similar operation to add rows to a repeating table.&amp;nbsp; In this case, use the command:&lt;/font&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;ExecuteAction /action=XCollectionInsert /xmltoedit=&lt;b&gt;&lt;i&gt;XmlToEdit&lt;/i&gt;&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;font size="2"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; For more information on using qRules and specifying commands, please see the qRules documentation.&lt;/font&gt;&lt;/p&gt;&lt;/font&gt;&lt;/font&gt;&lt;/font&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=39265" width="1" height="1"&gt;</description><category domain="http://www.infopathdev.com/blogs/jimmy/archive/tags/add+row/default.aspx">add row</category><category domain="http://www.infopathdev.com/blogs/jimmy/archive/tags/qRules/default.aspx">qRules</category><category domain="http://www.infopathdev.com/blogs/jimmy/archive/tags/repeating+section/default.aspx">repeating section</category></item><item><title>XPath's confusing not() function - inverting a boolean field</title><link>http://www.infopathdev.com/blogs/jimmy/archive/2008/10/25/xpath-s-confusing-not-function-inverting-a-boolean-field.aspx</link><pubDate>Sat, 25 Oct 2008 03:19:00 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:33522</guid><dc:creator>Jimmy</dc:creator><slash:comments>1</slash:comments><wfw:commentRss xmlns:wfw="http://wellformedweb.org/CommentAPI/">http://www.infopathdev.com/blogs/jimmy/rsscomments.aspx?PostID=33522</wfw:commentRss><comments>http://www.infopathdev.com/blogs/jimmy/archive/2008/10/25/xpath-s-confusing-not-function-inverting-a-boolean-field.aspx#comments</comments><description>&lt;p&gt;If you&amp;#39;ve ever tried to toggle a boolean field back and forth in an InfoPath form, or perform some behavior based on the inverse of a field&amp;#39;s value, you may have encountered a problem I found.&amp;nbsp; The not() function does not behave the way one would intuitively expect.&amp;nbsp; The online &lt;a class="" href="http://office.microsoft.com/en-us/infopath/HP011552811033.aspx"&gt;InfoPath function reference&lt;/a&gt; describes the function as follows:&lt;/p&gt;
&lt;table class=""&gt;

&lt;tr&gt;
&lt;td class=""&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;b class="bterm"&gt;not &lt;/b&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;/td&gt;
&lt;td class=""&gt;Returns true if the argument is false or null. Returns false if the argument is true or not null.&lt;/td&gt;
&lt;td class=""&gt;&lt;b class="bterm"&gt;&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;&lt;br /&gt;So what happens when a field is false and not null? 
&lt;p&gt;In actuality, any time the not() function contains a reference to a field, it returns &lt;em&gt;true&lt;/em&gt; if&amp;nbsp;the field exists, and &lt;em&gt;false&lt;/em&gt; if it does not exist, regardless of its value.&lt;/p&gt;
&lt;p&gt;To demonstrate this, I&amp;#39;ve created an InfoPath form with a boolean field in an optional section, and set up a rule and expression box like this:&lt;/p&gt;
&lt;p&gt;&lt;img style="WIDTH:749px;HEIGHT:466px;" height="466" src="http://www.infopathdev.com/blogs/jimmy/notFunction/notRule.jpg" width="749" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;When I preview the form, it exhibits the following behavior:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/notFunction/notChanges.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;not(field1)&lt;/strong&gt; is only true when &lt;em&gt;field1&lt;/em&gt; is non-existent, and when &lt;em&gt;field1&lt;/em&gt; has a value, &lt;strong&gt;not(field1)&lt;/strong&gt; is always false.&lt;br /&gt;What&amp;#39;s more, the button changes the value of &lt;em&gt;field1&lt;/em&gt; from true to false, but not from false to true. It&amp;#39;s only half of a toggle button!&lt;/p&gt;
&lt;p&gt;&lt;font size="+1"&gt;&lt;strong&gt;The solution:&lt;/strong&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Despite all this, we can obtain the inverse of a boolean field&amp;#39;s value with a little finagling.&lt;/p&gt;
&lt;p&gt;The XPath expression &lt;strong&gt;field1 = &amp;quot;true&amp;quot;&lt;/strong&gt; will have the value &amp;quot;false&amp;quot; when &lt;em&gt;field1&lt;/em&gt; is false, and &amp;quot;true&amp;quot; when &lt;em&gt;field1&lt;/em&gt; is true; in other words, it will always follow &lt;em&gt;field1&lt;/em&gt;&amp;#39;s value whenever &lt;em&gt;field1&lt;/em&gt; exists.&amp;nbsp;&amp;nbsp;We can&amp;nbsp;conclude that &lt;strong&gt;not(field1 = &amp;quot;true&amp;quot;)&lt;/strong&gt; will be the inverse of &lt;em&gt;field1&lt;/em&gt;&amp;#39;s value, and that is certainly the case. But if we are going to use an equality expression to determine &lt;em&gt;field1&lt;/em&gt;&amp;#39;s value, we may as well ditch the not() function entirely, and just use the expression &lt;strong&gt;field1 = &lt;em&gt;&amp;quot;false&amp;quot;&lt;/em&gt;&lt;/strong&gt;, which will be &amp;quot;true&amp;quot; when &lt;em&gt;field1&lt;/em&gt; is false, and &amp;quot;false&amp;quot; when &lt;em&gt;field1&lt;/em&gt; is true.&amp;nbsp; Here are the new settings for the expression box and the button&amp;#39;s rule:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/notFunction/goodNotRule.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;And when I preview the form, I see this behavior:&lt;/p&gt;
&lt;p&gt;&lt;img src="http://www.infopathdev.com/blogs/jimmy/notFunction/goodNotChanges.jpg" alt="" /&gt;&lt;/p&gt;
&lt;p&gt;Both expressions have the inverse of the value of &lt;em&gt;field1&lt;/em&gt; when it exists, and the button correctly toggles &lt;em&gt;field1&lt;/em&gt;&amp;#39;s value. One final note is that the two expressions have different values when &lt;em&gt;field1&lt;/em&gt; does not exist.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;&lt;img src="http://www.infopathdev.com/aggbug.aspx?PostID=33522" width="1" height="1"&gt;</description></item></channel></rss>