Hi,
I have two question about that.
First question ; I created two dynamic dropdown custom property called via external source ( With vRealize ORchestrator );
My vRO action code is ;
....
....
return ["Production,"Development"];
....
....
But, I want to write "Name" and "Values" different like picture below . Is that possible ?
return [{"name" : "Production", "value" : "PROD"}] --> this is not working...
My second question is ;
When I click the first dropdown, second drowdown values are coming but i want to first values set as default. Because i'll hide second dropdown and values should be set as default without user selection.
Thanks.
To do this, you'll need to change your action to return the type Properties. You can then do something like this sample:
if (continent == "NA"){
var props = new Properties();
props.put("US","United States");
props.put("Canada","Canada");
props.put("Mexico","Mexico");
return props;}
continent is my input value. I'm creating a list of properties here. The first entry is the value, the second entry is the display. At the end, return the variable in which your properties are stored. The visible result is like this:
Note that, by default, they will be sorted in ascending order alphabetically.
Second question, you can't hide a drop-down altogether unless you're using custom forms in vRA 7.4. Once you expose a drop-down, it's always there, but you can either force the value of leave it null depending on if you've set it as required or not.
To do this, you'll need to change your action to return the type Properties. You can then do something like this sample:
if (continent == "NA"){
var props = new Properties();
props.put("US","United States");
props.put("Canada","Canada");
props.put("Mexico","Mexico");
return props;}
continent is my input value. I'm creating a list of properties here. The first entry is the value, the second entry is the display. At the end, return the variable in which your properties are stored. The visible result is like this:
Note that, by default, they will be sorted in ascending order alphabetically.
Second question, you can't hide a drop-down altogether unless you're using custom forms in vRA 7.4. Once you expose a drop-down, it's always there, but you can either force the value of leave it null depending on if you've set it as required or not.
Hi daphnissov, It works. Thank you very much!
|
once list is longer e.g. 500+ results, does any of you have a solution for that problem?
I would like to use this on a XAAS blueprint (vra 7.3).
The dropdown should be associated with an input parameter of my workflow. The value returned should be a number, the displayed text a string. Since the output type of the action is array/properties, I'm not able to associate the action with the original type of the attribute, number. I defined the attribute as type "properties" but couldn't associate the action either. What type should I give to my attribute in order to be able to associate with the action?
Thanks
If you're not working with properties, then you work with array/string. The return type needs to also be adjusted as necessary.
@xian
How did you achieve this with Dynamic Types? My action has a return type of array/DynamicTypes:XXX and the Dropdown in the form has a type of DynamicTypes:XXX. My Dropdown turns out like you can see in the image below.
The dropdown shows a list of the available items, but with no label, and when I send the request with a randomly selected item the Input Parameter (which is of type DynamicTypes:XXX) is null.
Any other ideas on how to achieve label/value dropdown fields in XaaS forms? The Properties approach mentioned above does not sm to work for XaaS forms either. Using vRA 7.5.
Thanks!
Okay, solved it with the following workaround:
1) Create a Helper Action "DropdownParser" that has two functions to format & parse back ID+Name -> combined string:
Creates a string like so: MyDeploymentName (ID: 123123123123123123)
return {
// Formats a label+id into the final Dropdown Value.
format: function(name, id) {
return name + " (ID: " + id + ")"
},
// Parses the Dropdown Value back to label + id.
parse: function(dropdownValue) {
// Split the combined string
var splitString = dropdownValue.split(" (ID: ")
var name = splitString[0]
var id = splitString[1].slice(0, -1) // remove last character (the ")")
return {
name: name,
id: id
}
}
}
2) Create an Action to get the values for the dropdown field:
var dynamicTypes = [] // somehow get your array dynamicTypes
for each(var item in items) {
dynamicTypes.push(DropdownParser.format(item.name, item.id));
}
return dynamicTypes;
3) In vRA in your XaaS Blueprint or Resource Action form, go to your Dropdown -> Values -> External Values & Select the Action from Step 2
4) The dropdown should look like this:
5) In your Resource Action / XaaS Blueprint workflow parse the Dropdown string like so:
var parsedDropdownLabel = DropdownParser.parse(dropdownTest)
var id = parsedDropdownLabel.id
var name = parsedDropdownLabel.name
// e.g. use the ID to get your dynamicType again
6) Extra Step: Make sure to disallow the name of the dynamicType to include "(ID: " with form validation, so the combined string can always be parsed properly.
Bit much for a simple label/value dropdown form, but haven't found a better solution so far...