Skip to content

Commit cf9fe2c

Browse files
authored
Merge pull request #54368 from edburns/edburns-msft-function-nits
Nit and example
2 parents 9793eac + f2f0b63 commit cf9fe2c

File tree

1 file changed

+40
-1
lines changed

1 file changed

+40
-1
lines changed

articles/azure-resource-manager/managed-applications/create-uidefinition-functions.md

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.author: tomfitz
1111
# CreateUiDefinition functions
1212
This section contains the signatures for all supported functions of a CreateUiDefinition.
1313

14-
To use a function, surround the declaration with square brackets. For example:
14+
To use a function, surround the invocation with square brackets. For example:
1515

1616
```json
1717
"[function()]"
@@ -481,6 +481,45 @@ Assume `element1` and `element2` are undefined. The following example returns `"
481481
"[coalesce(steps('foo').element1, steps('foo').element2, 'foobar')]"
482482
```
483483

484+
This function is especially useful in the context of optional invocation that happens due to user action after the page loads. An example is if the constraints placed on one field in the UI depend on the currently selected value of another, **initially non-visible** field. In this case, `coalesce()` can be used to allow the function to be syntactically valid at page load time while having the desired effect when the user interacts with the field.
485+
486+
Consider this `DropDown`, which allows the user to choose from several different database types:
487+
488+
```
489+
{
490+
"name": "databaseType",
491+
"type": "Microsoft.Common.DropDown",
492+
"label": "Choose database type",
493+
"toolTip": "Choose database type",
494+
"defaultValue": "Oracle Database",
495+
"visible": "[bool(steps('section_database').connectToDatabase)]"
496+
"constraints": {
497+
"allowedValues": [
498+
{
499+
"label": "Azure Database for PostgreSQL",
500+
"value": "postgresql"
501+
},
502+
{
503+
"label": "Oracle Database",
504+
"value": "oracle"
505+
},
506+
{
507+
"label": "Azure SQL",
508+
"value": "sqlserver"
509+
}
510+
],
511+
"required": true
512+
},
513+
```
514+
515+
To condition the action of another field on the current chosen value of this field, use `coalesce()`, as shown here:
516+
517+
```
518+
"regex": "[concat('^jdbc:', coalesce(steps('section_database').databaseConnectionInfo.databaseType, ''), '.*$')]",
519+
```
520+
521+
This is necessary because the `databaseType` is initially not visible and therefore does not have a value. This causes the entire expression to not evaluate correctly.
522+
484523
## Conversion functions
485524
These functions can be used to convert values between JSON data types and encodings.
486525

0 commit comments

Comments
 (0)