Dynamically populate drop down in Attended Framework

Hi,

I am trying to get this to work properly, but I cannot seem to get it working. I am using attended automation framework to build an attended automation, and a new requirement is that I have to populate a drop-down with values that is dynamic in the input form. Let me explain:
I read an excel-file and thus I get a table named “dt_Svarsmottagare”, that contains the options for the drop down. This table contains two columns; one is the label that the user will see in the drop down list, and one is the value that will be passed from the selected item.

I created a drop-down select in the form “Form_Inputs-uiform” that is standard in the attended framework. I gave that drop-down the Field Key “svarsmottagare”.
I created a variable named dropdownOptions, that is a List variable, this will be the variable that I later use to assing to the Config variable.
For each row in the earlier read datatable “dt_Svarsmottagare”, I add a new row in “dropdownOptions” The rows that I add look like this:
New Dictionary(Of String, String) From {
{“label”, row(“key”).ToString},
{“value”, row(“value”).ToString}
}
In the end, I will have a list that contains all the rows from the datatable as a dictionary. Key value (label), and value (value).
I now assign the variable “dropdownOptions” to the Config variable Config(“svarsmottagare”), so far so good.

Now, since the attended framework automatically connects the options in my list if the same key exists within the Config(“svarsmottagare”), and the field key “svarsmottagare”, it does populate the drop-down with my options. And also correctly outputs the value that I can use later. The problem is that each option is displayed twice in the drop down list. The “Unique Options” in the display tab is checked.
I double and triple checked the input “dropdownOptions”, and it does not contain duplicates. When changing to Widget type “HTML 5” instead of “Choices JS”, I get only one unique options. However, that type cannot be empty, and thus the first option is selected by default. I do not want that.

Can anyone please advise me on how to solve the problem?

Hi @Kempe_William

I think you should remove all static options from the drop‑down in the form designer so the widget has zero predefined options. Leave only the Field Key. Then load every option only through Config(“svarsmottagare”). ChoicesJS will stop duplicating.

If one blank/“Select…” option is needed, add it manually as the first dictionary item in dropdownOptions before assigning to Config, instead of defining it in the form designer.

Happy Automation

I did not mention that, but of course the pre-defined values are all empty.
Also, while using the setting “Choices JS” as widget type, it correctly has an empty value in the start. It is only the “HTML 5” widget type that does not support an empty value.
Of course I could use “HTML 5” and then set the first value as “-- Select an option --”. However, that itself would be a value, and the validation stops working.

I could use do that, but then I need help with setting the validation for that component so that an error is displayed if the user tries to submit the form when the default “-- Select an option --” is the currecntly selected value.
This field is required