VMware Cloud Community
BScott66
Enthusiast
Enthusiast

Dynamic Dropdown Values (SQL Query)

Here's the dilemma...

I want to use a SQL query to populate a set of dropdown menu items, but everything I read discusses a select statement with a single column being returned.

Whats wrong with this is if I do the same thing in a Blueprint I get to provide a descriptive value presented in the dropdown and the actual value, which is the functionality I am looking to use in my vRO workflow.

Anyone know if this is possible? and if so how would I go about it?

I understand that I create an action which performs the query and then push the resultant values in the attribute, but how would I break this out and concat it to provide the values for the presentation and actual value.

For example:

DataCenter Code:

Presentation:                           Value:

New Jersey, Newark                DC01

New Jersey, Trenton                DC02

New York, White Planes           DC03


Being that the end user isn't going to know the data center designations I want to present the descriptive name to them so they can clearly understand, while what is actually used if what is required (Transparently!)

2 Replies
iiliev
VMware Employee
VMware Employee

Well, it should be relatively easy. Fetch the values from SQL query and populate an attribute of type Array/Any in a way that each attribute element is an array of 2 strings:

["New Jersey, Newark", "DC01"]

["New Jersey, Trenton", "DC02"]

["New York, White Planes", "DC03"]

Then, in your presentation use an action that returns Array/string, populated with the elements from this attribute at index 0; that is

["New Jersey, Newark"]

["New Jersey, Trenton"]

["New York, White Planes"]

Then, you need to have some code that takes the presentation value selected by the user and computes the corresponding DCxx value by iterating over the first attribute's values until it finds a matching string at index 0, and then return the string at index 1

BTW, it is also possible to get the same result without using Array/Any attribute; instead, use a couple of Array/string attributes - the first one for presentation values and the second one for DC values. When computing the matching DCxx value, you need to find at which index/position in the first attribute is the presentation value selected by the user, and the matching DCxx value will be the value at the same index/position in the second attribute.

sivakumarss
Enthusiast
Enthusiast

Hello.

Were you able to figure out a way to do this? I am also in the same situation. I want to return a list that is user friendly, but the actual value will be machine friendly. It is possible when we are creating a dropdown list property. But not when using an external action.

Reply
0 Kudos