Form dropdown using JSON as source


I have an HTTP process which retrieves the following JSON:

I would like to list these accounts in a Dropdown on a form. Any idea what expression I should use as nothing seems to work.



Here’s a way I handle these type of cases.

In your process flow, after the Http Task add a Script Task with Groovy language. Then, try the following code:

//retrieve JSON response
final def response = execution.getVariable("yourResponseVariableWithJson");

//response must not be null and empty
if (response != null && response.toString().length() > 2) {

    //array to store options in appropriate format
    final def String options = "[";

    //loop through JSON array
    response.each {
        //from each iterated object in array, get the account variable and add it to the options
        options += '{"id":"' + it.account + '","name":"' + it.account + '"},';
    //remove trailing comma
    options = options.substring(0, options.length() - 1);

    //close the array
    options += "]";

    //store options as a process variable
    execution.setVariable("myDropDownOptions", options);
} else {
    execution.setVariable("myDropDownOptions", "");

Then, you can reference the stored variable like this:

1 Like

That’s great. Thank you.

1 Like

Hi, do you have the groovy to get the selected value from the Dropdown after the form has been completed?

If the ID of the Dropdown is selectedatlasloanaccount, would it be…

final def response = execution.getVariable(“selectedatlasloanaccount”);?


That is correct.

All form values are submitted as process variables with the respective ID, hence the given snippet is enough to get the selected value.