Change value of a field in a Repeating Section based on number of occurances of the section - InfoPath Dev
in

InfoPath Dev

Change value of a field in a Repeating Section based on number of occurances of the section

Last post 05-28-2009 10:07 PM by swathip. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 05-27-2009 01:43 PM

    Change value of a field in a Repeating Section based on number of occurances of the section

    I am designing a contract form.  It works well if I enter all the information manually.  What I want to do is automate some fields.

    I have a date field named "Expiration_Date."

    Under the Expiration date field I have a Repeating Section (called Extension) with two other Date fields: "Former_Expiration_Date", and "New_Expiration_Date."

    The purpose of this repeating section is to have the user insert the section if an extension is needed.  There can be multiple extensions, hence the use of a repeating section.

    When the first extension is inserted I want the "Former Expiration Date" field's value to be set to match the value of the "Expiration Date" field.  Now if I add a second extension I want the second occurance of the Repeating Section's "Former Expiration Date" to be set from the value of the first occurance's "New_Expiration_Date" instead of the original "Expiration_Date", and the third occurance to be populated from the second and so on...

    I have tried to accomplish this using rules, but it doesn't seem to work.

    I created a rule in the "Extension" repeating section. The condition is: "if the expression, count(.) = 0" then the action to set a field's value would be "Former_Extension_Date = Extension_Date" 

    The second rule: The condition is: "if the expression, count(.) >= 1" then the action to set a field's value would be "Former_Extension_Date = preceding sybling:New_Extention_Date" 

    This does NOT work.

    If this makes sense to anyone, can this be accomplished with rules?  or do i have to write some code?  If code, then can someone give me some help with the code.  I am familiar with VB.

     

     

     

  • 05-27-2009 10:46 PM In reply to

    Re: Change value of a field in a Repeating Section based on number of occurances of the section

    Hi,

     

    You can get it using Rules. Follow the below steps.

    1. GO to repeating table properties. Add the rule1 as

    If count(/my:myFields/my:group1/my:group2) = 1 then set the Former_Extension_Date = Extension_Date

    2. Add the default value for Former_Expiration_Date as

    current()/../preceding-sibling::my:repeatinggroup[1]/my: New_Extention_Date

    Swathip
    www.ggktech.com
  • 05-28-2009 09:56 PM In reply to

    Re: Change value of a field in a Repeating Section based on number of occurances of the section

    swathip,

    Thanks for the reply! 

    When I complete just step 1 of the directions you posted, "Former Expiration Date" in the first occurance of the repeating section is populated with the value of "Expiration Date"

    When I complete just step 2, "Former Expiration Date" in the second occurance is populated with the value of the preceding section's "New Expiration Date"

    When I complete both steps,  the "Former Expiration Date" is not given a value when I insert the first section.  But, "Former Expiration Date" in the second occurance is populated with the value of the preceding section's "New Expiration Date"

    To make this short, step 1 works and step 2 works, but steps 1 and 2 do not work together.  It seems that the "set a field's value" action does not work on a field in a repeating section that has a default value set.

    Can anyone confirm this or offer a workaround?

  • 05-28-2009 10:07 PM In reply to

    Re: Change value of a field in a Repeating Section based on number of occurances of the section

    Hi,

    Delete all the rows in the repeating table and insert the new item then the both will work. Try out once.

    Swathip
    www.ggktech.com
Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.