Hi Thierry,
My apologies but I too am unsure of what you are trying to accomplish. It
sounds like you need to be able to enter a value in a field and then pass
this to your web service as, say a parameter, so that you can populate a
drop-down list based on the results of sending that value to your web
service - is this correct? If so, here is a sample of the steps I am using:
1) Create the C# Web Service
- Add a SQL DataAdapter (named daOrders) and set this to use the Orders
table from the Northwind SQL database (specifically the OrderID and
CustomerID fields)
- Create a DataSet (named dsOrders) from daOrders
- Add the following web method:
[WebMethod]
public DataSet GetOrders(string CustID)
{
if(CustID != "")
{
this.daOrders.SelectCommand.CommandText = "SELECT OrderID, CustomerID
FROM Orders WHERE CustomerID = '" + CustID + "'";
}
this.daOrders.Fill(dsOrders);
return dsOrders;
}
2) Create the InfoPath form
- Create a new, blank form
- Add a text box and named it: txtCustomerID
- Add a drop-down list box and named it: ddlOrders
- Add a new Data Connection to the above web service but choose to *not*
automatically get the data when the form is opened
- Right-click on ddlOrders, choose Properties and set the following
options:
- Data Connection: GetOrders
- Entries: Orders (use the Select XPath button to drilldown and select
Orders) and then click the "Filter Data" button, click Add and then set the
following options:
- 1st drop-down: select CustomerID from the Secondary Data Source
- 2nd drop-down: select "is equal to"
- 3rd drop-down: choose Select a Field or Group, select the Main data
source and then select txtCustomerID
** NOTE: What this filter is saying is: display data where the customerID
in the secondary data source is equal to the CustomerID that is entered in
the txtCustomerID field on the main form
- Click OK until you are back to the drop-down list Properties window
- Value: OrderID
- Display Name: OrderID
- Right-click on txtCustomerID, choose Properties and click the Rule button
- Click Add and complete the following:
- Click Add Action
- Choose: Set a Fields Value
- Click the button next to "Field" and select ddlOrders from the Main
data source
- Leave the Value field blank
- Click OK twice
- Click the Add button again and complete the following:
- Click the Add Action
- Choose: Query using a Data Connection
- Select the GetOrders data connection
- Click OK 4 times to get back to your InfoPath form
** NOTE: The first rule is used to clear previous entries in the drop-down
- the second rule actually queries the web service passing it the customer
ID that you enter.
3) Test
- Preview the form
- Enter BERGS in the text box and tab to the drop-down list - result: you
should see a series of Orders
- Enter ALFKI in the text box and tab to the drop-down list - result: you
should now see a series of different Orders
I hope all this helps Thierry!
Best Regards,
Scott L. Heim
Microsoft Developer Support
This posting is provided "AS IS" with no warranties, and confers no rights.