Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. Click on the selection control (Checkbox, Dropdown, Radio)
  2. Select Web Service from the Option Src dropdown


     
  3. Enter the URL of the RESTful web service that you are going to to retrieve the option data from. Data is retrieved using HTTP GET. The URL can contain templates and the options will be automatically updated whenever the value changes of any control referenced by a template in the URL.

    Ex: /http(s)://10.0.0.27/:8081/database/BIRT/allCustomers?_mediaType=json - This URL returns a list of all customers from a database The _mediaType parameter specifies that JSON results are returned. In this example, the Database Connector integrates with the database to execute the query. The Database Connector is a Restful service that returns results in XML or JSON.

     
  4. After entering the Options URL for your web service, click the save and test icon. Examine the results in the debug console to determine the Value and Label Bindings.
  5. The syntax for selection control options is <value>=<label>. The <label> is what will be displayed on your form/flow and the <value> is what is saved as the selected value when the user submits the form or completes the workflow.
    1. Enter the Value Binding - this is bind path of the option VALUES within the XML or JSON returned by the RESTful web service. Binding paths are specified with the '/' character used as a delimiter i.e. /resultSet/CountryID. The path locates the values to be extracted and set into the selection control options. If the data pointed to by the path is repeating, then the data extracted will be a collection of items. This is the value that will be stored in the XML submissions document when the form/flow is submitted/completed.
      The Value Binding can be determined by examining the resultSet in the frevvo debug console.

    2. Enter the Label Binding - this is the bind path of the option display LABELS within the XML or JSON returned by the RESTful web service. This label is displayed in the selection control options in Use mode. The Label Binding can be determined from the debug console by examining the resultSet in the debug console.

      1. Type the URL to your WebService in the Options Source property then click the save and test icon. Examine the resultSet in the debug console to determine the Value binding.

        Code Block
        titleExample 1: Results returned in JSON format
        If this is the JSON Data returned:  "totalResultsAvailable":2,
        "resultSet":[{"CountryName":"Argentina","CountryID":"1"},{"CountryName":"Aruba","CountryID":"12"},{"CountryName":"Bahamas","CountryID":"13"}]}
        
        If the Value Binding property is set to /resultSet/CountryID - the country id of the selected country will be stored in the Live Forms submission
        
        If the Label Binding is set to /resultSet/CountryName - the country names are what the user sees as the selection control options - Argentina, Aruba, Bahamas
        Code Block
        titleExample 2: Results returned in XML format
        If the results are returned in XML:   Notice that the XML uses namespaces and that they must be part of the bind path.
        
        <?xml version="1.0" encoding="UTF-8"?>
        <p0:allCountries xmlns:p0="http://www.frevvo.com/database/allCountries">
           <row>
              <CountryID>1</CountryID>
              <CountryName>Argentina</CountryName>
           </row>
           <row>
              <CountryID>12</CountryID>
              <CountryName>Aruba</CountryName>
           </row>
           <row>
              <CountryID>13</CountryID>
              <CountryName>Bahamas</CountryName>
           </row>
        </p0:allCountries
        
        If the Value Binding and Label Binding properties are be set to the same path: /p0:allCountries/row/CountryName - the Country Name will be included in the submission and Users will see the Country Names as the options of the selection control: Argentina, Aruba, Bahamas


  6. Click the save and test icon to test your form/flow.
  7. The Example below uses the Database Connector to retrieve a Customer List from a database. It also shows to construct the Value and Label Bindings from the XML results returned in the Debug Console.
Info

When using an _data parameter template in your options URL in a workflow, it may cause issues in steps that don't load the _data parameter and may even invalidate signed sections. One workaround is to store your _data parameter in a hidden control, and then use the template for that control in your Options Source URL instead.

Excerpt
hiddentrue

The Edmunds API web service returns a “vehicle makes” options list in JSON format and lets you narrow the options to a specific year. Design a form with a field for the user to enter a year and a checkbox, radio or dropdown control.


Follow these steps to populate the options of your selection control with the results returned from the Edmunds web service

  1. Edit the form in the Forms Designer 
  2. Click on the Selection control (checkbox, radio or dropdown) 
  3. Set the Options Src to Web Service 
  4. Set the Options URL to: https://api.edmunds.com/api/vehicle/v2/makes?state=new&year={year}&view=basic&fmt=json&api_key=p9v6s4uv6998k464u33m8jx3
  5. Set the Value Binding to:   /makes/niceName

  6. Set the Label Binding to:   /makes/name

  7. Save the form 

 When the user types something in the Year field, the web service is automatically called, the results are refreshed and the choices in the Car Makes checkbox will change based on whatever the web service returned. To test this, type in the year 2015 then the year 2017.

...