Skip to content

Commit ecda1d0

Browse files
authored
Merge pull request #111753 from ecfan/auto-convert
Add info about implicit data conversions
2 parents fb66b94 + ce08a40 commit ecda1d0

File tree

1 file changed

+95
-92
lines changed

1 file changed

+95
-92
lines changed

articles/logic-apps/workflow-definition-language-functions-reference.md

Lines changed: 95 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,14 @@ title: Reference guide for functions in expressions
33
description: Reference guide to functions in expressions for Azure Logic Apps and Power Automate
44
services: logic-apps
55
ms.suite: integration
6-
ms.reviewer: klam, logicappspm
6+
ms.reviewer: jonfan, logicappspm
77
ms.topic: conceptual
8-
ms.date: 02/03/2020
8+
ms.date: 04/23/2020
99
---
1010

1111
# Reference guide to using functions in expressions for Azure Logic Apps and Power Automate
1212

13-
For workflow definitions in [Azure Logic Apps](../logic-apps/logic-apps-overview.md)
14-
and [Power Automate](https://docs.microsoft.com/flow/getting-started), some
15-
[expressions](../logic-apps/logic-apps-workflow-definition-language.md#expressions)
16-
get their values from runtime actions that might not yet exist when your
17-
workflow starts running. To reference these values or process the values
18-
in these expressions, you can use *functions* provided by the
19-
[Workflow Definition Language](../logic-apps/logic-apps-workflow-definition-language.md).
13+
For workflow definitions in [Azure Logic Apps](../logic-apps/logic-apps-overview.md) and [Power Automate](https://docs.microsoft.com/flow/getting-started), some [expressions](../logic-apps/logic-apps-workflow-definition-language.md#expressions) get their values from runtime actions that might not yet exist when your workflow starts running. To reference these values or process the values in these expressions, you can use *functions* provided by the [Workflow Definition Language](../logic-apps/logic-apps-workflow-definition-language.md).
2014

2115
> [!NOTE]
2216
> This reference page applies to both Azure Logic Apps and Power Automate,
@@ -25,33 +19,23 @@ in these expressions, you can use *functions* provided by the
2519
> For more information about functions and expressions in Power Automate, see
2620
> [Use expressions in conditions](https://docs.microsoft.com/flow/use-expressions-in-conditions).
2721
28-
For example, you can calculate values by using math functions, such as the
29-
[add() function](../logic-apps/workflow-definition-language-functions-reference.md#add),
30-
when you want the sum from integers or floats. Here are other
31-
example tasks that you can perform with functions:
22+
For example, you can calculate values by using math functions, such as the [add()](../logic-apps/workflow-definition-language-functions-reference.md#add) function, when you want the sum from integers or floats. Here are other example tasks that you can perform with functions:
3223

3324
| Task | Function syntax | Result |
3425
| ---- | --------------- | ------ |
3526
| Return a string in lowercase format. | toLower('<*text*>') <p>For example: toLower('Hello') | "hello" |
3627
| Return a globally unique identifier (GUID). | guid() |"c2ecc88d-88c8-4096-912c-d6f2e2b138ce" |
3728
||||
3829

39-
To find functions [based on their general purpose](#ordered-by-purpose),
40-
review the following tables. Or, for detailed information about each function,
41-
see the [alphabetical list](#alphabetical-list).
30+
To find functions [based on their general purpose](#ordered-by-purpose), review the following tables. Or, for detailed information about each function, see the [alphabetical list](#alphabetical-list).
4231

4332
> [!NOTE]
44-
> In the syntax for parameter definitions, a question mark (?)
45-
> that appears after a parameter means the parameter is optional.
46-
> For example, see [getFutureTime()](#getFutureTime).
33+
> In the syntax for parameter definitions, a question mark (?) that appears after a parameter
34+
> means the parameter is optional. For example, see [getFutureTime()](#getFutureTime).
4735
4836
## Functions in expressions
4937

50-
To show how to use a function in an expression,
51-
this example shows how you can get the value from
52-
the `customerName` parameter and assign that value
53-
to the `accountName` property by using the
54-
[parameters()](#parameters) function in an expression:
38+
To show how to use a function in an expression, this example shows how you can get the value from the `customerName` parameter and assign that value to the `accountName` property by using the [parameters()](#parameters) function in an expression:
5539

5640
```json
5741
"accountName": "@parameters('customerName')"
@@ -76,10 +60,8 @@ so that you get a combined string, "SophiaOwen":
7660
"customerName": "@concat('Sophia', 'Owen')"
7761
```
7862

79-
Or, you can get string values from parameters. This example
80-
uses the `parameters()` function in each `concat()` parameter
81-
and the `firstName` and `lastName` parameters. You then pass
82-
the resulting strings to the `concat()` function so that
63+
Or, you can get string values from parameters. This example uses the `parameters()` function in each `concat()` parameter
64+
and the `firstName` and `lastName` parameters. You then pass the resulting strings to the `concat()` function so that
8365
you get a combined string, for example, "SophiaOwen":
8466

8567
```json
@@ -88,17 +70,14 @@ you get a combined string, for example, "SophiaOwen":
8870

8971
Either way, both examples assign the result to the `customerName` property.
9072

91-
Here are the available functions ordered by their general purpose,
92-
or you can browse the functions based on [alphabetical order](#alphabetical-list).
73+
Here are the available functions ordered by their general purpose, or you can browse the functions based on [alphabetical order](#alphabetical-list).
9374

9475
<a name="ordered-by-purpose"></a>
9576
<a name="string-functions"></a>
9677

9778
## String functions
9879

99-
To work with strings, you can use these string functions
100-
and also some [collection functions](#collection-functions).
101-
String functions work only on strings.
80+
To work with strings, you can use these string functions and also some [collection functions](#collection-functions). String functions work only on strings.
10281

10382
| String function | Task |
10483
| --------------- | ---- |
@@ -121,8 +100,7 @@ String functions work only on strings.
121100

122101
## Collection functions
123102

124-
To work with collections, generally arrays, strings,
125-
and sometimes, dictionaries, you can use these collection functions.
103+
To work with collections, generally arrays, strings, and sometimes, dictionaries, you can use these collection functions.
126104

127105
| Collection function | Task |
128106
| ------------------- | ---- |
@@ -143,10 +121,7 @@ and sometimes, dictionaries, you can use these collection functions.
143121

144122
## Logical comparison functions
145123

146-
To work with conditions, compare values and expression results,
147-
or evaluate various kinds of logic, you can use these logical comparison functions.
148-
For the full reference about each function, see the
149-
[alphabetical list](../logic-apps/workflow-definition-language-functions-reference.md#alphabetical-list).
124+
To work with conditions, compare values and expression results, or evaluate various kinds of logic, you can use these logical comparison functions. For the full reference about each function, see the [alphabetical list](../logic-apps/workflow-definition-language-functions-reference.md#alphabetical-list).
150125

151126
| Logical comparison function | Task |
152127
| --------------------------- | ---- |
@@ -165,12 +140,14 @@ For the full reference about each function, see the
165140

166141
## Conversion functions
167142

168-
To change a value's type or format, you can use these conversion functions.
169-
For example, you can change a value from a Boolean to an integer.
170-
For more information about how Logic Apps handles content types during
171-
conversion, see [Handle content types](../logic-apps/logic-apps-content-type.md).
172-
For the full reference about each function, see the
173-
[alphabetical list](../logic-apps/workflow-definition-language-functions-reference.md#alphabetical-list).
143+
To change a value's type or format, you can use these conversion functions. For example, you can change a value from a Boolean to an integer. For more information about how Logic Apps handles content types during conversion, see [Handle content types](../logic-apps/logic-apps-content-type.md). For the full reference about each function, see the [alphabetical list](../logic-apps/workflow-definition-language-functions-reference.md#alphabetical-list).
144+
145+
> [!NOTE]
146+
> Azure Logic Apps automatically converts values between some data types,
147+
> which means that you don't have to manually perform these conversions.
148+
> However, if you do so, you might experience unexpected display behaviors,
149+
> which don't affect the actual conversions, only how they are shown.
150+
> For more information, see [Implicit data type conversions](#implicit-data-conversions).
174151
175152
| Conversion function | Task |
176153
| ------------------- | ---- |
@@ -198,6 +175,39 @@ For the full reference about each function, see the
198175
| [xml](../logic-apps/workflow-definition-language-functions-reference.md#xml) | Return the XML version for a string. |
199176
|||
200177

178+
<a name="implicit-data-conversions"></a>
179+
180+
## Implicit data type conversions
181+
182+
Azure Logic Apps automatically or implicitly converts between some data types, so you don't have to manually convert these types. For example, if you use non-string values where strings are expected as inputs, Logic Apps automatically converts the non-string values into strings.
183+
184+
For example, suppose a trigger returns a numerical value as output:
185+
186+
`triggerBody()?['123']`
187+
188+
If you use this numerical output where string input is expected, such as a URL, Logic Apps automatically converts the value into a string by using the curly braces (`{}`) notation:
189+
190+
`@{triggerBody()?['123']}`
191+
192+
### Base64 encoding and decoding
193+
194+
Logic Apps automatically or implicitly performs base64 encoding or decoding, so you don't have to manually perform these operations by using the corresponding expressions:
195+
196+
* `base64(<value>)`
197+
* `base64ToBinary(<value>)`
198+
* `base64ToString(<value>)`
199+
* `base64(decodeDataUri(<value>))`
200+
* `concat('data:;base64,',<value>)`
201+
* `concat('data:,',encodeUriComponent(<value>))`
202+
* `decodeDataUri(<value>)`
203+
204+
> [!NOTE]
205+
> If you manually add these expressions to your logic app, for example, by using the expression editor,
206+
> navigate away from the Logic App Designer and return to the designer, the designer shows only the
207+
> parameter values. The expressions are preserved in code view only if you don't edit the parameter
208+
> values. Otherwise, Logic Apps removes the expressions from code view, leaving only the parameter values.
209+
> This behavior doesn't affect encoding or decoding, only whether the expressions are shown.
210+
201211
<a name="math-functions"></a>
202212

203213
## Math functions
@@ -962,6 +972,13 @@ And returns this result: `["hello"]`
962972

963973
Return the base64-encoded version for a string.
964974

975+
> [!NOTE]
976+
> Azure Logic Apps automatically performs base64 encoding and decoding,
977+
> which means that you don't have to manually perform these conversions.
978+
> However, if you do so, you might experience unexpected display behaviors,
979+
> which don't affect the actual conversions, only how they are shown.
980+
> For more information, see [Implicit data type conversions](#implicit-data-conversions).
981+
965982
```
966983
base64('<value>')
967984
```
@@ -992,6 +1009,13 @@ And returns this result: `"aGVsbG8="`
9921009

9931010
Return the binary version for a base64-encoded string.
9941011

1012+
> [!NOTE]
1013+
> Azure Logic Apps automatically performs base64 encoding and decoding,
1014+
> which means that you don't have to manually perform these conversions.
1015+
> However, if you do so, you might experience unexpected display behaviors,
1016+
> which don't affect the actual conversions, only how they are shown.
1017+
> For more information, see [Implicit data type conversions](#implicit-data-conversions).
1018+
9951019
```
9961020
base64ToBinary('<value>')
9971021
```
@@ -1022,11 +1046,14 @@ And returns this result:
10221046

10231047
### base64ToString
10241048

1025-
Return the string version for a base64-encoded string,
1026-
effectively decoding the base64 string.
1027-
Use this function rather than [decodeBase64()](#decodeBase64).
1028-
Although both functions work the same way,
1029-
`base64ToString()` is preferred.
1049+
Return the string version for a base64-encoded string, effectively decoding the base64 string. Use this function rather than [decodeBase64()](#decodeBase64), which is deprecated.
1050+
1051+
> [!NOTE]
1052+
> Azure Logic Apps automatically performs base64 encoding and decoding,
1053+
> which means that you don't have to manually perform these conversions.
1054+
> However, if you do so, you might experience unexpected display behaviors,
1055+
> which don't affect the actual conversions, only how they are shown.
1056+
> For more information, see [Implicit data type conversions](#implicit-data-conversions).
10301057
10311058
```
10321059
base64ToString('<value>')
@@ -1631,48 +1658,22 @@ And returns this result: `74`
16311658

16321659
<a name="decodeBase64"></a>
16331660

1634-
### decodeBase64
1661+
### decodeBase64 (deprecated)
16351662

1636-
Return the string version for a base64-encoded string,
1637-
effectively decoding the base64 string.
1638-
Consider using [base64ToString()](#base64ToString)
1639-
rather than `decodeBase64()`.
1640-
Although both functions work the same way,
1641-
`base64ToString()` is preferred.
1642-
1643-
```
1644-
decodeBase64('<value>')
1645-
```
1646-
1647-
| Parameter | Required | Type | Description |
1648-
| --------- | -------- | ---- | ----------- |
1649-
| <*value*> | Yes | String | The base64-encoded string to decode |
1650-
|||||
1651-
1652-
| Return value | Type | Description |
1653-
| ------------ | ---- | ----------- |
1654-
| <*decoded-base64-string*> | String | The string version for a base64-encoded string |
1655-
||||
1656-
1657-
*Example*
1658-
1659-
This example creates a string for a base64-encoded string:
1660-
1661-
```
1662-
decodeBase64('aGVsbG8=')
1663-
```
1664-
1665-
And returns this result: `"hello"`
1663+
This function is deprecated, so please use [base64ToString()](#base64ToString) instead.
16661664

16671665
<a name="decodeDataUri"></a>
16681666

16691667
### decodeDataUri
16701668

1671-
Return the binary version for a data uniform resource identifier (URI).
1672-
Consider using [dataUriToBinary()](#dataUriToBinary),
1673-
rather than `decodeDataUri()`.
1674-
Although both functions work the same way,
1675-
`dataUriToBinary()` is preferred.
1669+
Return the binary version for a data uniform resource identifier (URI). Consider using [dataUriToBinary()](#dataUriToBinary), rather than `decodeDataUri()`. Although both functions work the same way, `dataUriToBinary()` is preferred.
1670+
1671+
> [!NOTE]
1672+
> Azure Logic Apps automatically performs base64 encoding and decoding,
1673+
> which means that you don't have to manually perform these conversions.
1674+
> However, if you do so, you might experience unexpected display behaviors,
1675+
> which don't affect the actual conversions, only how they are shown.
1676+
> For more information, see [Implicit data type conversions](#implicit-data-conversions).
16761677
16771678
```
16781679
decodeDataUri('<value>')
@@ -1770,12 +1771,14 @@ And return this result: `2`
17701771

17711772
### encodeUriComponent
17721773

1773-
Return a uniform resource identifier (URI) encoded version for a
1774-
string by replacing URL-unsafe characters with escape characters.
1775-
Consider using [uriComponent()](#uriComponent),
1776-
rather than `encodeUriComponent()`.
1777-
Although both functions work the same way,
1778-
`uriComponent()` is preferred.
1774+
Return a uniform resource identifier (URI) encoded version for a string by replacing URL-unsafe characters with escape characters. Consider using [uriComponent()](#uriComponent), rather than `encodeUriComponent()`. Although both functions work the same way, `uriComponent()` is preferred.
1775+
1776+
> [!NOTE]
1777+
> Azure Logic Apps automatically performs base64 encoding and decoding,
1778+
> which means that you don't have to manually perform these conversions.
1779+
> However, if you do so, you might experience unexpected display behaviors,
1780+
> which don't affect the actual conversions, only how they are shown.
1781+
> For more information, see [Implicit data type conversions](#implicit-data-conversions).
17791782
17801783
```
17811784
encodeUriComponent('<value>')

0 commit comments

Comments
 (0)