Combo values from a Web Service
When completing a task, sometimes the users have to complete a field by selecting options from a combo box. A typical example is a list of countries, cities, products, etc. If the list is too long, writting the options manually would consume too much time. In these cases, it's very useful to get the combo options from a Web Service. Besides this, it can also be used to import data from an external system that you may have.
When setting up a process, add a new field in the Form tab. Select "Combo box" as data type and "Populate from external Web Service" as data source. Then click on "Set up your Web Service here..."
A new window will open in which you can set up the Web Service:
In the URL Web Service (REST) field enter the public URL of your Web Service.
(Optional) In case the Web Service receives some parameters, you can define them in the Input tab. You will need to specify the name and value for each parameter you add. You may select the value from one of your form fields or introduce it manually.
In the Output tab, map the response from the Web Service (which should be a JSON string) with the tag and value of the options for the combo. Both fields are required, but you can enter the same tag and value if you want.
In most cases, the system will show only the tag of the combo option. The advantage of discriminating between tag and value is that you can use the value as an Input parameter in another Web Service call. The typical example would be to select the value of a country to populate the combo with the cities of that country.
Finally, you can select the authentication used by your service on the Authentications tab
In the Web Service settings, press Accept.
In the field settings, press Accept.
Please take into account that the response format of the Web Service is the following: [{“country”: “Afghanistan”, “id”: “AF”}, {“country”: “Albania”, “id”: “AL” }]
The options of the combo will be populated while opening the process instance (as long as the field visibility is marked as editable or required) and whenever any of the fields defined as input parameters change. You can use a hidden field as an input parameter. In this case, the input parameter value is the one selected on the previous task.
The service call will always be made through an HTTP GET request.
How to set it up?
When setting up a process, add a new field in the Form tab. Select "Combo box" as data type and "Populate from external Web Service" as data source. Then click on "Set up your Web Service here..."
A new window will open in which you can set up the Web Service:
In the URL Web Service (REST) field enter the public URL of your Web Service.
(Optional) In case the Web Service receives some parameters, you can define them in the Input tab. You will need to specify the name and value for each parameter you add. You may select the value from one of your form fields or introduce it manually.
In the Output tab, map the response from the Web Service (which should be a JSON string) with the tag and value of the options for the combo. Both fields are required, but you can enter the same tag and value if you want.
In most cases, the system will show only the tag of the combo option. The advantage of discriminating between tag and value is that you can use the value as an Input parameter in another Web Service call. The typical example would be to select the value of a country to populate the combo with the cities of that country.
Finally, you can select the authentication used by your service on the Authentications tab
In the Web Service settings, press Accept.
In the field settings, press Accept.
Please take into account that the response format of the Web Service is the following: [{“country”: “Afghanistan”, “id”: “AF”}, {“country”: “Albania”, “id”: “AL” }]
The options of the combo will be populated while opening the process instance (as long as the field visibility is marked as editable or required) and whenever any of the fields defined as input parameters change. You can use a hidden field as an input parameter. In this case, the input parameter value is the one selected on the previous task.
The service call will always be made through an HTTP GET request.
Updated on: 18/05/2023
Thank you!