You can add a Custom Button or the On-Load feature to pull data into your form using a SOAP web service. This is a helpful feature which eliminates the need to enter data manually into your form. or that may change. You can populate entire Dropdown control lists with existing web service data to keep your forms up to date and accurate.
HOW TO SET UP A WEB SERVICE USING A CUSTOM BUTTON
In this example, I will use a Custom Button which will query a list of zipcodes and pull the appropriate data that matches the value I enter into a Textbox control. Put more simply, I can type zipcode ‘98115’ into my Textbox, then select a Custom Button which will query my web service and retrieve 'Seattle' as the value in my form.
Step 1: Add a Textbox control into your form
This Textbox will be the value that will talk to the web service and retrieve a city name. You’ll find the Textbox control in the left pane under Basic controls Later, when you set up your web service data source, you can choose to have a default value that can automatically fill this Textbox.
Step 2: Create the Query data source
In the right pane of the form creator, find the Query tab and select DATA SOURCE. Choose Web Service (SOAP) and select the NEXT button to open the query wizard.
For the next steps, please refer to the screenshot below.
- Name: Enter a name for this data connection. Space and special characters are not accepted. This is only a label for the data connection.
- URL: Copy and paste the web service URL you want to query into this Textbox. If you are not entering a User Name or Password in the next step, select CONNECT to activate your web service.
- User Name/Password: Depending on permissions, you can connect to your web service if needed but this isn't required. If you do enter your credentials for your web service, be sure to select the CONNECT button.
- Query data on load: Select this checkbox if you’d like your form to query data once it is opened. This way your form will automatically query your web service and return the specified data.
- Attach Credentials: If you are using your user name and password to connect to your web service, you can attach those credentials so users do not have to enter them manually on their device. Everyone using this form will connect to the web service with those specific credentials. This setting can be changed later in the form Properties if desired.
- Configuration: Select the data source you’d like to query in the dropdown given. As mentioned earlier, you can add a default value to a field; in this case, my Textbox (textbox1) I added earlier. If Query data on load is selected, the default value will be automatically queried when the form is opened. This will prompt any field in your form that is connected to the data source to pull data depending on the value of the Textbox. In my example, zipcode default value '98115' will be automatically queried when the form is opened, and will populate any specified field (I will use a Dropdown control shown in the next step).
Step 3: Add fields in your form to retrieve data
You can bind data to a Dropdown control or a field within a Repeating Section. For this example, I will use a Dropdown control to populate with my web service data. Using a Dropdown control is recommended for web services since you can bind them to data sources, and they can pull a list of data to populate the form. To accomplish this, first add a Dropdown control into your form and select it to see the control’s Properties. Under Items, you will see the option to Choose how you want to add your list:, Choose Data source, and select the EDIT DATA SOURCE button.
In the Data source wizard (see screenshot below) select the appropriate Data source, Value, and Display Name according to your web service. I have Show unique values only selected so that there won’t be any repeated values in my Dropdown. I will leave the Filter data options blank for this example and select SAVE.
Step 4: Add a Custom Button into your form
This Custom Button will be the trigger that searches your web service for data, and pulls a city name into your Dropdown according to the value in the Textbox. You will find the Custom Button under the Buttons tab in the left Controls pane as seen above. Once the Custom Button is added to your form, you will want to select the Logic tab and NEW RULE to create a rule for the button.
The goal here is to tell the Custom Button to query data when the Textbox has a value. Simply specify that when a field (textbox1) has a value, and the button is selected, to query data from your web service (ZipCodeWS). See the screenshot below for an example.
When the rule is complete, select SAVE, then SAVE & PUBLISH your form to update the form on your device.
USING REPEATING SECTIONS WITH WEB SERVICES
Another option for binding a data source would be to use a Repeating Section with a nested control. You will need to insert a Repeating Section control in your form and insert a Textbox or Dropdown control within it.
Select your Repeating Section to see the Bindings option, and select EDIT DATA SOURCE.
Choose what Data source (ZipCodeWS) to query, and the Data Source Column (city) that corresponds to the Textbox or Dropdown field you added within your Repeating Section (textbox2).
Below is a screenshot of how the form will appear on the device. After selecting the button, the City value changes depending on what ZipCode is in the Textbox.
HOW TO SET UP A WEB SERVICE TO PULL DATA ON LOAD
You can also use the On Load feature to populate full lists of data from your web service. This avoids using a Custom Button, and you can have a Dropdown that is automatically populated with a web service list. The steps to complete this scenario are similar, but we will skip the Custom Button step.
Step 1: Add a Dropdown
Find the Dropdown control in the left pane and select it to insert one into your form. Feel free to modify the Dropdown in the properties however you'd like; I will simply change the Label.
Step 2: Create a Query Data Source
As we did before, we need to create a Data Source to query a list for the Dropdown. In the right pane of the form creator, select the Query tab and + Data Source.
Below is an example of how your web service data source will appear. Basically, the only difference will be the Configuration, and your web service's URL will connect to a list of data (the Custom Button example only pulled a single value related to the zip code). Also, be sure to select the option to Query data on load so that your Dropdown will fill with data when you open your form on your device.
- Name: Enter a name for this data connection. Space and special characters are not accepted. This is only a label for the data connection. I have labeled mine LettersWS because I will be pulling a list of letters into my Dropdown.
- URL: Copy and paste the web service URL you want to query into this Textbox. If you are not entering a User name or Password in the next step, select CONNECT to activate your web service.
- User Name/Password: Depending on permissions, you can connect to your web service if needed but this isn't required.
- Query data on load: This is an important step for this scenario. Be sure to check Query data on load so that your form will query your web service when the form is opened on your device.
- Attach Credentials: If you are using your User name and Password to connect to your web service, you can attach those credentials so users do not have to enter them manually on their device. Everyone using this form will connect to the web service with those specific credentials. This setting can be changed later in the form Properties if desired.
- Configuration: Select the Data source you’d like to query. Here, you are choosing what list of data you'd like to pull from your web service.
Step 3: Edit the data source for your Dropdown
Select your Dropdown to view the control's Properties. Under Items you will see options to Choose how you want to add your list. From those choices, select Data source and the EDIT DATA SOURCE button.
In the Data source wizard, choose your Data source, along with the Value and Display Name. Same as before, I will skip the filtering options for this example.
SAVE the Data source information and SAVE & PUBLISH your form to update your form. Below is a screenshot of the Dropdown pulling data from a web service to a form on my mobile device.