Dev Notes

Notes on Development with Microsoft Technologies

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.


Author: Chris Quick

I have been a developer of web based solutions since early 2001 delivering solutions to a wide array of organizations using ASP, ASP.NET and SharePoint. I was introduced to SharePoint in 2003 when the consulting firm I worked for at the time introduced it into the workplace. I began working with MOSS 2007 as soon as Microsoft released the RTM version in November 2006. The platform was implemented at the organization I worked for in 2007 and went live in March of that year. I was tasked with the administration and ongoing development of the platform. I currently work as a SharePoint Architect with Artis Consulting, developing solutions for a wide variety of business problems. The goal of this blog is to share my discoveries developing solutions with SharePoint. I welcome your comments and feedback to any post -- and I welcome suggestions for future topics.

4 thoughts on “Copy InfoPath Rules

  1. This solution is simply great.. works perfectly and just made my day!!! Thanks for posting such good stuff.

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

  3. 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.


  4. Pingback: Tweets that mention Copy InfoPath Rules « SharePoint Dev Notes --

Leave a Reply

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

You are commenting using your 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