Search This Blog

Monday, June 20, 2011

Pre-Populating a Repeating Table in InfoPath 2010

Scenario:  Client wants their users to be able to add and delete choices from a table.   The number of choices will vary from form to form.  So this calls for a repeating table.   But how can I pre-populate the form in a way that the users can delete the pre-filled data if it's not needed?

I searched and search the Google-sphere for this one.  The closest I came was this solution for InfoPath 2007 from    S.Y.M. Wong-A-Ton

InfoPath 2010 does things a bit differently, but that blog helped along the way:

 1.  Add a repeating table to your form.




 2.  In the fields section, right click on the field and change the property to "Repeating".


 3.  On the form, right click on the field and "Change Control" to "repeating table".

Now we have a nested repeating table.  

 4.  Right click on the outermost table.
 5.  Click on "Repeating Table Properties"
 6.  Click "Edit Default Values".


 7.  Right Click on the repeating field.
 
 8.  Click on "Add another (field name) below.
 9.  Repeat step 8 until all the fields to be pre-populated are created.  


10.  Click on the 2nd field created.  Fill in the desired value.


11.   Repeat until all values are added
NOTE:  Leave the first  field empty.  
Completing this field will pre-populate any new fields to be added.
12.  Click ok.
13.  Click "Customized Commands"
14.  Optional:   Deselect all actions and click ok.

NOTE:  This will prevent the users form adding new columns multiple ways.

15.  Deselect the "Show Insert button and hint text" command.

NOTE:  This will remove the "Add New Item" from the outermost repeating table. 
Failure to do this step will enable users to add multiple versions of the innermost table.


What it looks like:

NOTE:  I configured my  "Customized Commands" so that my users can only remove these items.
 Any questions??

7 comments:

  1. When I use calculated values (using the fx button) in the fields, all values pre-populate to the same calculated number. I am not able to enter different forumlae for different fields. Is that a restriction in InfoPath 2010?

    ReplyDelete
  2. Good question: what variable is changing in the formula? Something has to be different in each default value. I'm not sure how well this technique would work in a look-up list...that may be what you need to use.

    ReplyDelete
  3. I am working on a form with similar requirement, so I followed your steps. but the "Add Another ....Above" and "Add another ... below" menus were all disabled.

    http://www.infopathdev.com/forums/p/21920/75736.aspx#75736

    Are you building a web browser form or filler form? Thx

    ReplyDelete
  4. Thank you works for me. Just to add value I provide the setps to set the default value of new items is created:

    1. Select the inner table.

    2. Open rules by clicking the “Mange Rules” icon in the ribbon if it is not already open.

    3. Add a new Action rule and all it “Set New value”
    4. Insert “count(../preceding-sibling::my:InnerTableName) = 0” condition.

    5. Add a set value action and add the value there.

    Javier Martinez

    ReplyDelete
  5. Thanks again for the solution, quick question - can you pre-populate a rows with multiple columns?

    Take care,
    Collincc

    ReplyDelete
  6. great article. this helped me alot.

    Thanks!

    ReplyDelete
  7. Thanks for a great read. As Steve Jobs said : “Innovation is what separates leaders from followers.”

    ReplyDelete