Skip to content

Commit 91c93f9

Browse files
Merge pull request #201537 from microsoft-dustin/new-template-expression-functions
New template expression functions
2 parents 3fd6794 + 5782ff2 commit 91c93f9

File tree

1 file changed

+237
-6
lines changed

1 file changed

+237
-6
lines changed

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

Lines changed: 237 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,14 @@ To work with strings, you can use these string functions and also some [collecti
9393

9494
| String function | Task |
9595
| --------------- | ---- |
96+
| [chunk](../logic-apps/workflow-definition-language-functions-reference.md#chunk) | Split a string or collection into chunks of equal length. |
9697
| [concat](../logic-apps/workflow-definition-language-functions-reference.md#concat) | Combine two or more strings, and return the combined string. |
9798
| [endsWith](../logic-apps/workflow-definition-language-functions-reference.md#endswith) | Check whether a string ends with the specified substring. |
9899
| [formatNumber](../logic-apps/workflow-definition-language-functions-reference.md#formatNumber) | Return a number as a string based on the specified format |
99100
| [guid](../logic-apps/workflow-definition-language-functions-reference.md#guid) | Generate a globally unique identifier (GUID) as a string. |
100101
| [indexOf](../logic-apps/workflow-definition-language-functions-reference.md#indexof) | Return the starting position for a substring. |
102+
| [isFloat](../logic-apps/workflow-definition-language-functions-reference.md#isInt) | Return a boolean that indicates whether a string is a floating-point number. |
103+
| [isInt](../logic-apps/workflow-definition-language-functions-reference.md#isInt) | Return a boolean that indicates whether a string is an integer. |
101104
| [lastIndexOf](../logic-apps/workflow-definition-language-functions-reference.md#lastindexof) | Return the starting position for the last occurrence of a substring. |
102105
| [length](../logic-apps/workflow-definition-language-functions-reference.md#length) | Return the number of items in a string or array. |
103106
| [nthIndexOf](../logic-apps/workflow-definition-language-functions-reference.md#nthIndexOf) | Return the starting position or index value where the *n*th occurrence of a substring appears in a string. |
@@ -119,6 +122,7 @@ To work with collections, generally arrays, strings, and sometimes, dictionaries
119122

120123
| Collection function | Task |
121124
| ------------------- | ---- |
125+
| [chunk](../logic-apps/workflow-definition-language-functions-reference.md#chunk) | Split a string or collection into chunks of equal length. |
122126
| [contains](../logic-apps/workflow-definition-language-functions-reference.md#contains) | Check whether a collection has a specific item. |
123127
| [empty](../logic-apps/workflow-definition-language-functions-reference.md#empty) | Check whether a collection is empty. |
124128
| [first](../logic-apps/workflow-definition-language-functions-reference.md#first) | Return the first item from a collection. |
@@ -127,7 +131,9 @@ To work with collections, generally arrays, strings, and sometimes, dictionaries
127131
| [join](../logic-apps/workflow-definition-language-functions-reference.md#join) | Return a string that has *all* the items from an array, separated by the specified character. |
128132
| [last](../logic-apps/workflow-definition-language-functions-reference.md#last) | Return the last item from a collection. |
129133
| [length](../logic-apps/workflow-definition-language-functions-reference.md#length) | Return the number of items in a string or array. |
134+
| [reverse](../logic-apps/workflow-definition-language-functions-reference.md#reverse) | Reverse the order of items in an array. |
130135
| [skip](../logic-apps/workflow-definition-language-functions-reference.md#skip) | Remove items from the front of a collection, and return *all the other* items. |
136+
| [sort](../logic-apps/workflow-definition-language-functions-reference.md#sort) | Sort items in a collection. |
131137
| [take](../logic-apps/workflow-definition-language-functions-reference.md#take) | Return items from the front of a collection. |
132138
| [union](../logic-apps/workflow-definition-language-functions-reference.md#union) | Return a collection that has *all* the items from the specified collections. |
133139
|||
@@ -269,6 +275,7 @@ For the full reference about each function, see the
269275
| [convertFromUtc](../logic-apps/workflow-definition-language-functions-reference.md#convertFromUtc) | Convert a timestamp from Universal Time Coordinated (UTC) to the target time zone. |
270276
| [convertTimeZone](../logic-apps/workflow-definition-language-functions-reference.md#convertTimeZone) | Convert a timestamp from the source time zone to the target time zone. |
271277
| [convertToUtc](../logic-apps/workflow-definition-language-functions-reference.md#convertToUtc) | Convert a timestamp from the source time zone to Universal Time Coordinated (UTC). |
278+
| [dateDifference](../logic-apps/workflow-definition-language-functions-reference.md#dateDifference) | Return the difference between two dates as a timespan. |
272279
| [dayOfMonth](../logic-apps/workflow-definition-language-functions-reference.md#dayOfMonth) | Return the day of the month component from a timestamp. |
273280
| [dayOfWeek](../logic-apps/workflow-definition-language-functions-reference.md#dayOfWeek) | Return the day of the week component from a timestamp. |
274281
| [dayOfYear](../logic-apps/workflow-definition-language-functions-reference.md#dayOfYear) | Return the day of the year component from a timestamp. |
@@ -1211,6 +1218,48 @@ These examples show the different supported types of input for `bool()`:
12111218

12121219
## C
12131220

1221+
<a name="chunk"></a>
1222+
1223+
### chunk
1224+
1225+
Split a string or array into chunks of equal length.
1226+
1227+
```
1228+
chunk('<collection>', '<length>')
1229+
chunk([<collection>], '<length>')
1230+
```
1231+
1232+
| Parameter | Required | Type | Description |
1233+
| --------- | -------- | ---- | ----------- |
1234+
| <*collection*> | Yes | String or Array | The collection to split |
1235+
| <*length*> | Yes | The length of each chunk |
1236+
|||||
1237+
1238+
| Return value | Type | Description |
1239+
| ------------ | ---- | ----------- |
1240+
| <*collection*> | Array | An array of chunks with the specified length |
1241+
||||
1242+
1243+
*Example 1*
1244+
1245+
This example splits a string into chunks of length 10:
1246+
1247+
```
1248+
chunk('abcdefghijklmnopqrstuvwxyz', 10)
1249+
```
1250+
1251+
And returns this result: `['abcdefghij', 'klmnopqrst', 'uvwxyz']`
1252+
1253+
*Example 2*
1254+
1255+
This example splits an array into chunks of length 5.
1256+
1257+
```
1258+
chunk(createArray(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), 5)
1259+
```
1260+
1261+
And returns this result: `[ [1,2,3,4,5], [6,7,8,9,10], [11,12] ]`
1262+
12141263
<a name="coalesce"></a>
12151264

12161265
### coalesce
@@ -1594,6 +1643,37 @@ dataUriToString('data:text/plain;charset=utf-8;base64,aGVsbG8=')
15941643

15951644
And returns this result: `"hello"`
15961645

1646+
<a name="dateDifference"></a>
1647+
1648+
### dateDifference
1649+
1650+
Return the difference between two timestamps as a timespan. This function subtracts `startDate` from `endDate`, and returns the result as timestamp in string format.
1651+
1652+
```
1653+
dateDifference('<startDate>', '<endDate>')
1654+
```
1655+
1656+
| Parameter | Required | Type | Description |
1657+
| --------- | -------- | ---- | ----------- |
1658+
| <*startDate*> | Yes | String | A string that contains a timestamp |
1659+
| <*endDate*> | Yes | String | A string that contains a timestamp |
1660+
|||||
1661+
1662+
| Return value | Type | Description |
1663+
| ------------ | ---- | ----------- |
1664+
| <*timespan*> | String | The difference between the two timestamps, which is a timestamp in string format. If `startDate` is more recent than `endDate`, the result is a negative value. |
1665+
||||
1666+
1667+
*Example*
1668+
1669+
This example subtracts the first value from the second value:
1670+
1671+
```
1672+
dateDifference('2015-02-08', '2018-07-30')
1673+
```
1674+
1675+
And returns this result: `"1268.00:00:00"`
1676+
15971677
<a name="dayOfMonth"></a>
15981678

15991679
### dayOfMonth
@@ -2052,31 +2132,42 @@ And return these results:
20522132

20532133
### float
20542134

2055-
Convert a string version for a floating-point number to an actual floating point number. You can use this function only when passing custom parameters to an app, for example, a logic app or flow.
2135+
Convert a string version for a floating-point number to an actual floating point number. You can use this function only when passing custom parameters to an app, for example, a logic app workflow or Power Automate flow. To convert floating-point strings represented in locale-specific formats, you can optionally specify an RFC 4646 locale code.
20562136

20572137
```
2058-
float('<value>')
2138+
float('<value>', '<locale>'?)
20592139
```
20602140

20612141
| Parameter | Required | Type | Description |
20622142
| --------- | -------- | ---- | ----------- |
20632143
| <*value*> | Yes | String | The string that has a valid floating-point number to convert. The minimum and maximum values are the same as the limits for the float data type. |
2144+
| <*locale*> | No | String | The RFC 4646 locale code to use. <br><br>If not specified, default locale is used. <br><br>If *locale* isn't a valid value, an error is generated that the provided locale isn't valid or doesn't have an associated locale. |
20642145
|||||
20652146

20662147
| Return value | Type | Description |
20672148
| ------------ | ---- | ----------- |
20682149
| <*float-value*> | Float | The floating-point number for the specified string. The minimum and maximum values are the same as the limits for the float data type. |
20692150
||||
20702151

2071-
*Example*
2152+
*Example 1*
20722153

20732154
This example creates a string version for this floating-point number:
20742155

20752156
```
2076-
float('10.333')
2157+
float('10,000.333')
2158+
```
2159+
2160+
And returns this result: `10000.333`
2161+
2162+
*Example 2*
2163+
2164+
This example creates a string version for this German-style floating-point number:
2165+
2166+
```
2167+
float('10.000,333', 'de-DE')
20772168
```
20782169

2079-
And returns this result: `10.333`
2170+
And returns this result: `10000.333`
20802171

20812172
<a name="formatDateTime"></a>
20822173

@@ -2537,6 +2628,75 @@ int('10')
25372628

25382629
And returns this result: `10`
25392630

2631+
<a name="isFloat"></a>
2632+
2633+
### isFloat
2634+
2635+
Return a boolean indicating whether a string is a floating-point number. By default, this function uses the invariant culture for the floating-point format. To identify floating-point numbers represented in other locale-specific formats, you can optionally specify an RFC 4646 locale code.
2636+
2637+
```
2638+
isFloat('<string>', '<locale>'?)
2639+
```
2640+
2641+
| Parameter | Required | Type | Description |
2642+
| --------- | -------- | ---- | ----------- |
2643+
| <*value*> | Yes | String | The string to examine |
2644+
| <*locale*> | No | String | The RFC 4646 locale code to use |
2645+
|||||
2646+
2647+
| Return value | Type | Description |
2648+
| ------------ | ---- | ----------- |
2649+
| <*boolean-result*> | Boolean | A boolean that indicates whether the string is a floating-point number |
2650+
2651+
*Example 1*
2652+
2653+
This example checks whether a string is a floating-point number in the invariant culture:
2654+
2655+
```
2656+
isFloat('10,000.00')
2657+
```
2658+
2659+
And returns this result: `true`
2660+
2661+
*Example 2*
2662+
2663+
This example checks whether a string is a floating-point number in the German locale:
2664+
2665+
```
2666+
isFloat('10.000,00', 'de-DE')
2667+
```
2668+
2669+
And returns this result: `true`
2670+
2671+
<a name="isInt"></a>
2672+
2673+
### isInt
2674+
2675+
Return a boolean that indicates whether a string is an integer.
2676+
2677+
```
2678+
isInt('<string>')
2679+
```
2680+
2681+
| Parameter | Required | Type | Description |
2682+
| --------- | -------- | ---- | ----------- |
2683+
| <*string*> | Yes | String | The string to examine |
2684+
|||||
2685+
2686+
| Return value | Type | Description |
2687+
| ------------ | ---- | ----------- |
2688+
| <*boolean-result*> | Boolean | A boolean that indicates whether the string is an integer |
2689+
2690+
*Example*
2691+
2692+
This example checks whether a string is an integer:
2693+
2694+
```
2695+
isInt('10')
2696+
```
2697+
2698+
And returns this result: `true`
2699+
25402700
<a name="item"></a>
25412701

25422702
### item
@@ -3837,6 +3997,36 @@ Here's how the example returned array might look where the outer `outputs` objec
38373997
]
38383998
```
38393999

4000+
<a name="reverse"></a>
4001+
4002+
### reverse
4003+
4004+
Reverse the order of items in a collection. When you use this function with [sort()](#sort), you can sort a collection in descending order.
4005+
4006+
```
4007+
reverse([<collection>])
4008+
```
4009+
4010+
| Parameter | Required | Type | Description |
4011+
| --------- | -------- | ---- | ----------- |
4012+
| <*collection*> | Yes | Array | The collection to reverse |
4013+
|||||
4014+
4015+
| Return value | Type | Description |
4016+
| ------------ | ---- | ----------- |
4017+
| [<*updated-collection*>] | Array | The reversed collection |
4018+
||||
4019+
4020+
*Example*
4021+
4022+
This example reverses an array of integers:
4023+
4024+
```
4025+
reverse(createArray(0, 1, 2, 3))
4026+
```
4027+
4028+
And returns this array: `[3,2,1,0]`
4029+
38404030
## S
38414031

38424032
<a name="setProperty"></a>
@@ -3999,6 +4189,47 @@ slice('Hello World', 3, -1) // Returns 'lo Worl'.
39994189
slice('Hello World', 3, 3) // Returns ''.
40004190
```
40014191

4192+
<a name="sort"></a>
4193+
4194+
### sort
4195+
4196+
Sort items in a collection. You can sort the collection objects using any key that contains a simple type.
4197+
4198+
```
4199+
sort([<collection>], <sortBy>?)
4200+
```
4201+
4202+
| Parameter | Required | Type | Description |
4203+
| --------- | -------- | ---- | ----------- |
4204+
| <*collection*> | Yes | Array | The collection with the items to sort |
4205+
| <*sortBy*> | No | String | The key to use for sorting the collection objects |
4206+
|||||
4207+
4208+
| Return value | Type | Description |
4209+
| ------------ | ---- | ----------- |
4210+
| [<*updated-collection*>] | Array | The sorted collection |
4211+
||||
4212+
4213+
*Example 1*
4214+
4215+
This example sorts an array of integers:
4216+
4217+
```
4218+
sort(createArray(2, 1, 0, 3))
4219+
```
4220+
4221+
And returns this array: `[0,1,2,3]`
4222+
4223+
*Example 2*
4224+
4225+
This example sorts an array of objects by key:
4226+
4227+
```
4228+
sort(createArray(json('{ "first": "Amalie", "last": "Rose" }'), json('{ "first": "Elise", "last": "Renee" }'), "last")
4229+
```
4230+
4231+
And returns this array: `[{ "first": "Elise", "last": "Renee" }, {"first": "Amalie", "last": "Rose" }')]`
4232+
40024233
<a name="split"></a>
40034234

40044235
### split
@@ -5319,4 +5550,4 @@ Here's the result: `Paris`
53195550

53205551
## Next steps
53215552

5322-
Learn about the [Workflow Definition Language](../logic-apps/logic-apps-workflow-definition-language.md)
5553+
Learn about the [Workflow Definition Language](../logic-apps/logic-apps-workflow-definition-language.md)

0 commit comments

Comments
 (0)