Dropdown programmed always returns 0 instead of the text entry

Good morning, everyone,

I just created a form in which I put dropdowns. I created an instance and a method for each and by programming, the first one filled the second one. That works, but when I want to get the selected values back, I get a value of 0 (zero) instead of the displayed value. However much I turn it in all directions, I only get 0.

If I do a debug like $evm.log(:info, "value is : #{$evm.root[‘dialog_name_dropdown’]}), normaly, I should be receive a text value, but instead I receive the 0 number.

Do you have an idea for the solution. Do we need to refresh the cache and if so how can we do that?

Thank you for your help.

Can you post the code, that sets the value for the dropdown?

Dropdown values are a key/value pair. The key is the actual value passed to Automate and the value is a human readable description displayed to the user.

When are you trying to read the value back? Is it while loading another dynamic element in the same Dialog? After you clicked submit in the StateMachine?

Have you tried ObjectWalker to debug the problem?

Check the type of the field in the dialog definition.

There is a choice between string and integer (“Value type” field), and I believe it would behave like you’re describing when set to integers but filled with strings.


I didn’t even think to go check on the type.

A big thank you.

1 Like


I come back to you with a similar problem. We have created a form with dropdown and when we want to recover the value, we always have an integer. I made sure the value is a string and not an integer.

By programmation, we fill a dropdown:
$evm.object[‘read_only’] = false
$evm.object[“data_type”] = “string”
$evm.object[‘values’] = dialog_hash

This call is made from a method, just before to send the form

Do you have a suggestion to make to me or tell me where the problem is?

Thank you for your help.

Depends… does the returned integer at least correspond to the string value there?

(As in, does "123" become 123 or something else?)

If it does correspond, sounds like it could be a bug in the code detecting whether to treat the values as integers or strings.

If it does not… can you be more specific about the values please?

Since the code, we have no difficulty in retrieving information from textboxes, but impossible for dropdowns.

The information entered in the dropdown is a string of type “google.com”. More precisely a DNS suffix and the value that is returned is an integer 0


we must simply retrieve the selection

Thank for your help.

Do you think I can work around this problem by loading a global variable each time the selection changes and I can retrieve the new value by the global variable?

@eclarizio Any idea about this one please?

I have no idea what happens when dynamically setting a dropdown data type…


Just a screenshot with the value type with “String”

@himdel Dynamically setting the type should work when refreshing other fields, but currently when submitting it does not work because automate does not run on submit. Though, it looks like he has the type set to “string” in the editor anyway, so it shouldn’t be a problem.

@netgus What version of the product are you running? Also, I’m kind of confused as to what you are trying to do, because to me it sounded like you have a dynamic dropdown (dd_dns_zone_name) you are trying to get values from, but it is not refreshing any other fields according to your screenshot so no other automate methods would be running after choosing from that drop down.

@netgus I don’t know if you can attach things on this forum but can you export your dialog and automate datastore and try to post them here?

The version we use is:

In the form, we have a dropdown that is filled by programming, but, indeed there are no fields to refresh.

On the other hand, in a textbox, which serves as a validation, we need to retrieve the choice that was made in the dropdown to compare it to the value that was entered in other textbox. We have no problem retrieving a value from any textbox, but impossible for a dropdown.

The scenario is as follows:
A person entering data into a textbox that triggers the refreshing of another textbox that retrieves the value of the textbox and compares it to the entry.

I hope it’s clearer.

and thank you again for your availability

We did some tests and if I remove the programming from the dropdown and fill it in manually. It works. So, I deduce that it’s the code that’s not good.

My code:
dialog_hash = {}
bRW = true
XX = $evm.instance_find("/xxxx/Config/Environment/xxx/#{$evm.root[‘dialog_cf_env’]}")["#{$evm.root[‘dialog_cf_env’]}"]
get_suffix = XX[‘FQDN_Suffix’].split(",")
get_suffix.each_with_index do |val,idx|
dialog_hash[idx] = val.to_s
if idx >= 1 then bRW = false end

$evm.object[‘read_only’] = bRW
$evm.object[“data_type”] = “string”
$evm.object[‘values’] = dialog_hash

I found

Just replace
dialog_hash[idx] = val.to_s
dialog_hash[val] = val.to_s

Thank you for your help

Very probably, the bug is in https://github.com/ManageIQ/ui-components/pull/319/files#diff-00d19c827d9a3dbda806aceea2c35d8bR29

Looks like it is doing some conversion that should be based on whether field.data_type === 'integer' but it’s not looking there.

If you can check that replacing that line with just const description = option[1] fixes your problem, I can do a proper fix.

Alternately, if you can’t, please create a proper BZ or (github) issue with exact steps how to reproduce :).