Home > Paul Busby, Work > Recursive rules in InfoPath–How to prevent

Recursive rules in InfoPath–How to prevent

 

A while ago I had a scenario in an InfoPath form where the user could either enter an amount or a percentage value. This value would then get added to a total already in the form. The requirement is that the user enters either value and the form then calculates the other one.

So if I enter a number then the percentage gets calculated. If I entered the percentage then the number value gets calculated.

So I quickly setup some rules so that when the value changed the percentage or the whole numbers gets calculated and updates the relevant field. This creates a loop of continually updated fields.

 

I had hoped that some clever InfoPath “stuff” would just make this work and I wouldn’t have to worry about the issue. This didn’t work and caused the form to fail or the fields would not update correctly.

 

The solution to this problem is that you need a third field to control the updates. Mine is called “Calculating” and is a simple Boolean field.

 

Now in the rules for Field1 (number) and Field2 (percentage) the first thing to do is to check that calculating = 0 then set calculating = 1 and then set your field. At the end set Calculating back to 0.

 

This is just a very simple implementation of a lock but it stops the InfoPath rules going crazy.

 

image

Pictures explain everything

via Buzz Blog http://paulbuzzblog.wordpress.com/2013/09/24/recursive-rules-in-infopathhow-to-prevent/

Chris Stretton
Paul is a an expert SharePoint and Project Server developer and is responsible for designing and implementing custom solutions on client systems using the latest SharePoint and .NET technologies.
Paul has extensive experience with SharePoint systems across all sizes of implementation, ranging from small to large farms and has an excellent understanding of all the elements of SharePoint.

This article has been cross posted from paulbuzzblog.wordpress.com (original article)

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Please log in using one of these methods to post your comment:

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

%d bloggers like this: