Home > 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

Advertisements
Categories: work Tags: ,
  1. No comments yet.
  1. No trackbacks yet.

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

%d bloggers like this: