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>
	</xsf:rule>
</xsf:ruleSet>
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>
	</xsf:rule>
</xsf:ruleSet>

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

Advertisements

4 thoughts on “Copy InfoPath Rules

  1. You should click with the right button on the manifest.xsf and choose the Design option, and then save a new File as Template.

  2. Your solution seems awesome but I am definitely missing something here. I saved my template as a source files; then closed my template. I used a Notepad (text editor) to view the XML in manifest.xsf and copied the ruleset of one rule to a button’s ruleset. Then saved the .xsf file. Reopened my template to reveiw the rules of the button and the rules are not there. What am i doing wrong? Please help.

    Tricia

Leave a Reply

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

WordPress.com Logo

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s