Recursive rules - InfoPath Dev
in

InfoPath Dev

Recursive rules

Last post 08-11-2011 02:32 AM by eliasen. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 08-08-2011 06:28 AM

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Recursive rules

    Hi

    I am creating a form that has two textboxes. One is for kW (kiloWatt) and the other is for HP (HorsePower). The form is a IP2007 form running under forms Services on SP2007.

    There is a rule for conversion between the two:

    HP = kW / 0.7355

    and hence kW = HP * 0.7355

    Problem is that I need users to be able to enter the number they have and calculate the other. So I have entered a rule on kW: HP = round(kW / 0.7355) and I have entered a rule on HP: kW = round(HP * 0.7355)

    This almost always goes well, but there are situations where it doesn't go well.

    If I enter a kW, InfoPath seems to be doing this:

    1. Calculate HP as round(kW / 0.7355)

    2. Since HP has changed, calculate kW as round(HP * 0.7355)

    Luckily IP knows to stop now and not keep going endlessly.

    Problem is, if I enter HP=1000, then after calculating kW and then recalculating HP, HP is set to 1001. This won't do for me at all - but I don't really know what to do. I can't just save the value with decimals and show the value with no decimals - I need the actual values that are saved in the Main DataSource to have no decimals because of later purposes.

    Any ideas?

    Thanks.

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
    Filed under:
  • 08-08-2011 11:57 AM In reply to

    1. Create a boolean field called calculating in either your main or a secondary data source and have its default value as false.

    2. Change both of your rules to perform these three actions:

      1. Set calculating = true
      2. Calculate and set the other field
      3. Set calculating = false

    3. Change both of your rules to only run when the condition calculating = false is met.

    4. You're all set!

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 08-11-2011 02:32 AM In reply to

    • eliasen
    • Top 500 Contributor
      Male
    • Joined on 10-07-2010
    • Aalborg, Denmark
    • Posts 33

    Thanks, Jimmy - that did the trick.

    eliasen, representing himself and not the company he works for.
    Microsoft BizTalk MVP
    Blog: http://blogs.eliasen.dk/technical/
Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.