I am writing createUIdefinition.json ARM template. I want to dynamically select the value of certain parameter - lets call parameterC in maintemplate.json based on the provided values of A and B in UI definition template. Now B is optional and existance of it depends on value selected by user for variable A. So I have wrote template something like below:
"name": "dropdownA",
"type": "Microsoft.Common.DropDown",
"label": "dropdownA",
"defaultValue": "1.1",
"constraints": {
"allowedValues": [
{
"label": "1.1",
"value": "1-1"
},
{
"label": "1.2",
"value": "1-2"
},
{
"label": "1.3",
"value": "1-3"
},
]
},
"visible": true
"name": "dropdownB",
"type": "Microsoft.Common.DropDown",
"label": "dropdown B",
"defaultValue": "valueX",
"toolTip": "Choose value",
"constraints": {
"allowedValues": [
{
"label": "valueX",
"value": "x"
},
{
"label": "valueY",
"value": "y"
}
]
},
"visible": "[contains(createArray('1-1','1-2'), basics('dropdownA'))]" ### make this element visible only if value of A is in ['1-1','1-2']
However, I found while I add this condition : [contains(createArray('1-1','1-2','1-2'), basics('dropdownA'))] for dropdown B, Azure UI keep waiting and basically doesn't go to summary page of offer nor it reflects any error that I can debug. If I remove [contains(createArray('1-1','1-2','1-2'), basics('dropdownA'))] , it works fine.
Am i missing something?
If the visible condition for DropDownB is set as:
"visible": "[not(equals('1-3', basics('dropdownA')))]"
,
I am able to see the DropDownB only visible when the selected value of DropDownA is either 1-1 or 1-2, which I believe is what you exactly expected.
Hope this helps!
Here is my fully tested createUiDefinition template which works.
{
"$schema": "https://schema.management.azure.com/schemas/0.1.2-preview/CreateUIDefinition.MultiVm.json",
"handler": "Microsoft.Compute.MultiVm",
"version": "0.1.2-preview",
"parameters": {
"basics": [
{
"name": "dropdownA",
"type": "Microsoft.Common.DropDown",
"label": "dropdownA",
"defaultValue": "1.1",
"constraints": {
"allowedValues": [
{
"label": "1.1",
"value": "1-1"
},
{
"label": "1.2",
"value": "1-2"
},
{
"label": "1.3",
"value": "1-3"
}
]
},
"visible": true
},
{
"name": "dropdownB",
"type": "Microsoft.Common.DropDown",
"label": "dropdown B",
"defaultValue": "valueX",
"toolTip": "Choose value",
"constraints": {
"allowedValues": [
{
"label": "valueX",
"value": "x"
},
{
"label": "valueY",
"value": "y"
}
]
},
"visible": "[not(equals('1-3', basics('dropdownA')))]"
}
],
"steps": [],
"outputs": {}
}
}
Reference: CreateUiDefinition functions
Update: @bmoore-msft is right.
If you refer to the reference link above, createArray() is not supported as part of the CreateUiDefinition functions