Using Rules to Passively Insure Postive or Negative Values in InfoPath

Several projects that I have completed using InfoPath over the last few months have made use of numerical values for calculations. For example, a recent form was used upon employee termination to determine if the employee owed money to the organization or if the organization owed money to the employee. It makes a significant difference if the form is allowed to present both deductions and additions as positive values, so we pursued a path to transparently pick up the appropriate numbers. If the person completing the form enters a positive number into a field that expects a negative number, the value is silently converted for the employee without any prompts or error messages. If the employee enters the values as negative, then nothing needs to be corrected. Here’s how this was accomplished.

Continue reading “Using Rules to Passively Insure Postive or Negative Values in InfoPath”


InfoPath over jQuery?

A recent project had my team asking some really difficult questions on what technology should be applied to a business problem. We had been tasked to create a specialized survey in SharePoint that would need to change based on the items selected for each question. The question would present five or six possible answers, but all other answers might need to be cleared if a specific answer was selected.

For example, the question might read “Who needs to sign-off on this project?” and include “Information Technology, Public Relations, Marketing, Executive Leadership and No Sign-off Required” as possible answers. The person completing the survey could select any combination of the first four options. However; if the person completing the survey selected No Sign-off Required, all of the other answers become irrelevant so they should be cleared.

Continue reading “InfoPath over jQuery?”

Copy InfoPath Rules

One of the most frustrating tasks in InfoPath 2007 is the duplication of similar or identical rules. If you have several views that will apply very similar, or identical rules, the inability to copy those rules leaves you to have to recreate each and every action stored in the rule. This is not such a big deal if there are only a couple of actions, but if you have multiple actions that need to be executed, this can be a painful way to modify and create rules.

What if there were a way to stub out the rules that will be duplicated and just copy them making simply changes back in the UI when done? Here’s how:

Create the first complete set of actions for the rule that needs to be duplicated/copied while in the InfoPath designer. Go to each place where the rule needs to be duplicated and create an initial rule with a single action of some kind – also be sure to provide a meaningful name. Save the InfoPath from as source files (File > Save as Source Files). Close the form and use a text editor to view the XML in manifest.xsf.

Find the node xsf:ruleSets. This is a list of all the rules defined in your form and each one will have an xsf:ruleset followed by the actions contained in the ruleset. Copy the actions from your completed ruleset to an incomplete ruleset.

Completed Rules
<xsf:ruleSet name="ruleSet_2">
	<xsf:rule caption="Query Profile Using Root URL" isEnabled="yes">
		<xsf:queryAction adapter="GetUserProfileByName - Ops"></xsf:queryAction>
		<xsf:assignmentAction targetField="my:LoadFromOpsSuccess" expression=""true""></xsf:assignmentAction>
		<xsf:assignmentAction targetField="my:FirstName" expression="xdXDocument:GetDOM("GetUserProfileByName - Ops")/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData/s0:Values/s0:ValueData/s0:Value[../../../s0:Name = "FirstName"]"></xsf:assignmentAction>
		<xsf:assignmentAction targetField="my:LastName" expression="xdXDocument:GetDOM("GetUserProfileByName - Ops")/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData/s0:Values/s0:ValueData/s0:Value[../../../s0:Name = "LastName"]"></xsf:assignmentAction>
		<xsf:assignmentAction targetField="my:DisplayName" expression="xdXDocument:GetDOM("GetUserProfileByName - Ops")/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData/s0:Values/s0:ValueData/s0:Value[../../../s0:Name = "PreferredName"]"></xsf:assignmentAction>
		<xsf:assignmentAction targetField="my:Account" expression="xdXDocument:GetDOM("GetUserProfileByName - Ops")/dfs:myFields/dfs:dataFields/s0:GetUserProfileByNameResponse/s0:GetUserProfileByNameResult/s0:PropertyData/s0:Values/s0:ValueData/s0:Value[../../../s0:Name = "AccountName"]"></xsf:assignmentAction>
		<xsf:assignmentAction targetField="@my:Source" expression=""Ops""></xsf:assignmentAction>
Incomplete Ruleset
<xsf:ruleSet name="ruleSet_2">
	<xsf:rule caption="Query Profile Using Root URL" isEnabled="yes">
						<span style="color:#000000;background:#FFFF00;"><!-- REPLACE ALL INNER NODES --></span>
		<xsf:queryAction adapter="GetUserProfileByName - Ops"></xsf:queryAction>

Save the file and open InfoPath 2007 again into design mode. You rules should now be copied and ready to tweak.

Updating InfoPath DataSources

In a recent project, I was getting frustrated with InfoPath not executing validation rules properly after I had added a new node to the Main Data Source. In effect, over 50 items would not be able to be updated because the data validation would always fail.

After some investigation, I discovered a setting in the Form Options > Versioning screen that allowed me to either automatically upgrade the form when opened or allow the user to upgrade the form. Setting this to automatic corrected my issue and allowed the business users to continue working as normal.