Skip to content

Commit d7ad30e

Browse files
committed
On branch edburns-msft-function-nits In this context, functions are invoked, not declared. Add example of coalesce() use from Quinn McHugh.
modified: articles/azure-resource-manager/managed-applications/create-uidefinition-functions.md
1 parent d668995 commit d7ad30e

File tree

1 file changed

+43
-1
lines changed

1 file changed

+43
-1
lines changed

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

Lines changed: 43 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,48 @@ Assume `element1` and `element2` are undefined. The following example returns `"
481481
"[coalesce(steps('foo').element1, steps('foo').element2, 'foobar')]"
482482
```
483483

484+
> [!NOTE]
485+
> This function is especially in the context of optional invocation that happens due to user action after the page loads. For example, 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.
486+
>
487+
> Consider this `DropDown` which allows the user to choose from several different database types.
488+
>
489+
> ```
490+
> {
491+
> "name": "databaseType",
492+
> "type": "Microsoft.Common.DropDown",
493+
> "label": "Choose database type",
494+
> "toolTip": "Choose database type",
495+
> "defaultValue": "Oracle Database",
496+
> "visible": "[bool(steps('section_database').connectToDatabase)]"
497+
> "constraints": {
498+
> "allowedValues": [
499+
> {
500+
> "label": "Azure Database for PostgreSQL",
501+
> "value": "postgresql"
502+
> },
503+
> {
504+
> "label": "Oracle Database",
505+
> "value": "oracle"
506+
> },
507+
> {
508+
> "label": "Azure SQL",
509+
> "value": "sqlserver"
510+
> }
511+
> ],
512+
> "required": true
513+
> },
514+
> ```
515+
>
516+
> If we want to condition the action of another field on the current
517+
> chosen value of this field, we can use `coalesce()` to enable this
518+
> use case.
519+
>
520+
> ```
521+
> "regex": "[concat('^jdbc:', coalesce(steps('section_database').databaseConnectionInfo.databaseType, ''), '.*$')]",
522+
> ```
523+
>
524+
> 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.
525+
484526
## Conversion functions
485527
These functions can be used to convert values between JSON data types and encodings.
486528

0 commit comments

Comments
 (0)