Business Requirement: Incrementing Date in Repeating Table
The business requirement of this post covers the following topic: each time the user adds a line in a Repeating Table on an InfoPath form, the Date Field of the line should increment by one day automatically.
An example is elaborated in this post with the by default installed Expense Report Sample. Each time an Expense line is added, the Date of the Expense line will be incremented with one day.
Solution
- Add a new Date Field to the Data Source.
- Set the Default Value of the Date Field in the Repeating Table equal to the value of the previously added Date Field (LastAddedDate). Make sure you uncheck Update this value when the result of the formula is recalculated.
- Add a Rule to the Repeating Table which adds a day to the LastAddedDate Field (Use the function addDays for it).
- Add a second Rule to the Repeating Table which sets the value of Date Field of the Repeating Table equal to the LastAddedDate Field.
- Add a Rule to the Date Field in the Repeating Table which sets the value of the LastAddedDate Field equal to the value of the Date Field in the Repeating Table.
Result: Date Field in Repeating Table gets default value
If you enter as Date 4/04/2010 for the first Expense line, the Date will be automatically set to 5/04/2010 on the second added Expense line and so on. If you enter as Date 10/4/2010 for the third added Expense line, the adding of Dates will go further from April the 10th for Expense lines added afterwards.
Sorry it is not working with my infopath 2010, can u possibly send me the code to have a look please?
manglai658@hotmail.com
Post a Comment