Populate a Dropdown with Data from a REST API¶
Scenario¶
Use this walkthrough when a form dropdown should load its selectable values from an external REST service instead of a static list.
Prerequisites¶
- a process definition with a form you can edit
- permission to create or edit a script module
- access from the Emakin runtime to the target REST service
Steps¶
Define a Script Module¶
When making a client-side service call, such as calling it from a form, defining a script module is mandatory. This approach helps manage your API integrations in a more organised and reusable manner.
- Create a script module.
- Name it according to the integration you are working with. In this example, the module is named
External.

- Open the module and define a function named
GetCountriesto call the external service.
Use a function like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | |
This example:
- calls
https://restcountries.com/v3.1/all - requests only the
cca3andnamefields - returns the JSON response to the caller
- exports the function so it can be reused elsewhere in the process definition
Save the script module before continuing.
Create the Dropdown¶
- Open the form you want to edit.
- Add a new dropdown widget.
- Give it a meaningful label such as
Select a Country.
Configure the Data Source¶
The note below reflects the UI behavior documented for version 8.5 and may differ in newer versions.
If ScriptDataSource is not available directly in the dropdown designer, edit the widget XML manually.

- Open the dropdown widget.
- Select XML to edit the widget markup.
- Insert the following snippet under
<DataSources>:
1 2 3 4 5 6 7 8 | |
In this example:
TextFormatdisplays the country nameValueFormatstores the country code- the
<Content>block callsExternal.GetCountriesAsync()
Info
Even though the function in your script module is named GetCountries, when making a client-side call from the form, you must append Async to the function name (GetCountriesAsync). This is required to ensure that the data is fetched asynchronously in the client-side environment.
Save the XML after making the change.
Test the Form¶
- Save and deploy the process definition.
- Open the initiating task.
- Confirm the dropdown is populated with values from the REST service.
- Select one option and inspect the resulting XML.
The stored value should follow this pattern:
1 2 3 4 5 6 7 8 | |
Result¶
The dropdown now loads its selectable values from an external REST API through a reusable script module.
Troubleshooting¶
If the dropdown does not populate as expected:
- Check that
GetCountriesis defined and exported from the script module. - Make sure the form calls
GetCountriesAsync, notGetCountries. - Confirm that the API endpoint is reachable from the Emakin runtime.
- Verify that the service returns data in the expected structure.
- Review the
ScriptDataSourceXML and make sure theTextFormatandValueFormatmatch the response payload.
Download and Try it Yourself¶
To help you get started quickly, we’ve provided a downloadable definition of the process described in this guide. You can import this Populate dropdown from REST.xml into your environment and test the dropdown functionality with the data from the REST API.