Assume you want to call a Web service and pass in parameters supplied by the user at runtime. The Web service will populate a drop-down list field in a repeating table. The user should then be able to add rows at will to the repeating table and in each row make a selection from the drop-down list. When the user selects an option, the corresponding repeating table row fields are populated with the correct data row values for the value selected.
This example assumes the web service returns data in a structure similar to the following where all information related to a part number is in sibling nodes:
<font face="Verdana" color="black" size="2"><root>
<materials>
<partrecord>
<partno></partno>
<vendorpartno></vendorpartno>
<description></description>
…
</partrecord>
<partrecord>
…
</partrecord>
…
</materials>
</root></font>
Start by creating a new InfoPath project in Visual Studio. In the InfoPath IDE add a text box, a repeating table with a drop-down list, and a text box with the following properties:
Text Box |
Name |
wsParam1 |
Data Type |
Text (string) |
Drop-Down List Box |
Name |
field2 |
Data Type |
Text (string) |
List box entries |
Lookup values in a data connection to the database, Web service, file, or SharePoint library or list |
Text Box |
Name |
autofilledtext |
Data Type |
Text (string) |
Set up the drop-down list box to be populated dynamically at run time as described in Setting Secondary Data Source Web Service parameters using C# at runtime in InfoPath We also need to add a hidden field to the main DOM with the following properties:
Name |
hdnSelectedVal |
Data Type |
Text (string) |