Inconsistent Calculated data - InfoPath Dev
in

InfoPath Dev

Inconsistent Calculated data

Last post 01-11-2008 11:27 AM by Greg Collins. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 01-08-2008 02:36 PM

    Inconsistent Calculated data

    I have a form that has nested repeating tables (see below).  Each row needs to be uniquely identified.  I have a rule for the day when a new day is added to increment the day_id and the detail_id (day_id=day_id+1 and detail_id=detail_id+1 respectively).  Also, the  detail table has a rule to increment the detail_id when a new detail row is added.  Both id fields have default values of one.

    When I test the form, and add a day, the day_id does not increment until I add another day row.  The detail_id increments correctly.  I noticed in the rules that the set detail_id rule is first and the day_id rule is second.  I switched the order, and now the day_id increments properly and the detail_id increments after two additions.

    Any thoughts?  BTW, sorry for the line spacing, I tried to tighten it up, but I could not get the code to stick.

     

    Thanks,

    Ren

    THE WAY IT SHOULD BE

    <day>
    	<day_id/> = 1
    	<details>
    		<detail>
    			<detail_id/> =1
    		</detail>
    		<detail>
    			<detail_id/> =2
    		</detail>
    	</details>
    </day>
    <day>
    	<day_id/> =2
    	<details>
    		<detail>
    			<detail_id/> =3
    		</detail>
    		<detail>
    			<detail_id/> =4
    		</detail>
    	</details>
    </day>
     
    WITH THE DETAIL_ID RULE FIRST
    <day>
    	<day_id/> = 1
    	<details>
    		<detail>
    			<detail_id/> =1
    		</detail>
    		<detail>
    			<detail_id/> =2
    		</detail>
    	</details>
    </day>
    <day>
    	<day_id/> =1
    	<details>
    		<detail>
    			<detail_id/> =3
    		</detail>
    		<detail>
    			<detail_id/> =4
    		</detail>
    	</details>
    </day>

     

    WITH THE DAY_ID FIRST

    <day>
    	<day_id/> = 1
    	<details>
    		<detail>
    			<detail_id/> =1
    		</detail>
    		<detail>
    			<detail_id/> =1
    		</detail>
    	</details>
    </day>
    <day>
    	<day_id/> =2
    	<details>
    		<detail>
    			<detail_id/> =2
    		</detail>
    		<detail>
    			<detail_id/> =3
    		</detail>
    	</details>
    </day>

     

  • 01-08-2008 04:44 PM In reply to

    Re: Inconsistent Calculated data

    When you say "uniquely identified" -- does that mean uniquely identified across sessions, or just within a session? If just within a session, then you can assign a default value formula to get the count(previous::day_id)+1, for example. These then will always be numbered based on order.

    If you need to have it unique across sessions, then you need to store the latest number value somewhere... assign that value on add, then increment it--or increment it and then assign it (whichever). But the value must be stored in the main dom.

  • 01-09-2008 10:34 AM In reply to

    Re: Inconsistent Calculated data

    Greg,

     Yes, the values are cross session and I am storing the values in the main dom in their own elements.  The issue is when I increment, the first time a new row is added, the xpath expression does not fire off (or that's what appears to be happening). This is cross session.  For example, If it is a brand new form and 1 row, the element number is 1.  When I add the second row, the rules should increment and and then assign, but the number stays at 1.  When I add the 3rd row, the number will increment to 2.  After that, the number will increment by one.  If I save the form with 5 rows and open it up, when I add the 6th row, it will not increment and it will start to increment on the 7th row.

     

    I don't know if I said this before, for this project I am using IP 2007 on Windows XP.

     Thank you,

     Ren

  • 01-09-2008 02:03 PM In reply to

    Re: Inconsistent Calculated data

    Here's what I did, and it was working fine for me:

    I took your same basic schema (except I had a days node around the repeating day node).

    Then I added two fields: day_id_seed, and detail_id_seed. I set both of these to a default value of 1.

    For day_id... I set the default value to day_id_seed (and unchecked update value when result changes check box). I added a rule to update day_id_seed to this nodes value + 1.

    For detail_id... I set the default value to detail_id_seed (and unchecked the update value when result changes check box). I added a rule to update detail_id_seed to this nodes value + 1.

    Then I added all the fields and repeating sections to the view, and previewed... everything worked as expected: inserting randomly, deleting rows, etc.

    Hope this helps.

     

  • 01-11-2008 09:03 AM In reply to

    Re: Inconsistent Calculated data

    Greg,

     I think I have nailed it down. 

    Just to let you know, my schema is for the most part the same way you have it, I just stripped away the fluff for the example.

     

    I placed expression boxes linked to the seed fields and previewed the form.  When I add a day row, the seed increments, but the actual day_id does not update.  It appears the the rule incrementing the seed fires after IP populates the day_id default value.  Again, this only happens on the first addition.  After that IP seems to increment the seed then populate the day_id default.

    Strange,

     

    Ren

  • 01-11-2008 11:27 AM In reply to

    Re: Inconsistent Calculated data

    Strange, I didn't have any issue at all with how I described it. The rule is only supposed to fire after the id value updates. This rule then increments the seed (after the update). The id value is a "default value formula" and not a rule. And it is set to not update when the caclulation changes.

Page 1 of 1 (6 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.