Skip to content

Commit 0df86ab

Browse files
Merge pull request #261175 from ecfan/select
Azure Logic Apps: [GitHub 114473] Select action - Create array with integers or strings, rather than objects
2 parents dea8e5d + 7f3fd09 commit 0df86ab

File tree

3 files changed

+47
-6
lines changed

3 files changed

+47
-6
lines changed

articles/logic-apps/logic-apps-data-operations-code-samples.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: logic-apps
55
ms.suite: integration
66
ms.reviewer: estfan, azla
77
ms.topic: conceptual
8-
ms.date: 08/20/2022
8+
ms.date: 12/13/2023
99
---
1010

1111
# Data operation code samples for Azure Logic Apps
@@ -324,7 +324,7 @@ To try the [**Parse JSON** action example](../logic-apps/logic-apps-perform-data
324324

325325
## Select
326326

327-
To try the [**Select** action example](../logic-apps/logic-apps-perform-data-operations.md#select-action), here are the action definitions you can use:
327+
To try the [**Select** action example](../logic-apps/logic-apps-perform-data-operations.md#select-action), the following action definitions create a JSON object array from an integer array:
328328

329329
```json
330330
"actions": {
@@ -363,6 +363,43 @@ To try the [**Select** action example](../logic-apps/logic-apps-perform-data-ope
363363
},
364364
```
365365

366+
The following example shows action definitions that create a string array from a JSON object array, but for this task, next to the **Map** box, switch to text mode (![Icon for text mode.](media/logic-apps-perform-data-operations/text-mode.png)) in the designer, or use the code view editor instead:
367+
368+
```json
369+
"actions": {
370+
"Initialize_variable_-_object_array": {
371+
"type": "InitializeVariable",
372+
"inputs": {
373+
"variables": [
374+
{
375+
"name": "myObjectArray",
376+
"type": "Array",
377+
"value": [
378+
{"Val":"1", "Txt":"One"},
379+
{"Val":"2", "Txt":"Two"},
380+
{"Val":"4", "Txt":"Four"},
381+
{"Val":"10", "Txt":"Ten"}
382+
]
383+
}
384+
]
385+
},
386+
"runAfter": {}
387+
},
388+
"Select": {
389+
"type": "Select",
390+
"inputs": {
391+
"from": "@body('myObjectArray')?['value']",
392+
"select": "@{item()?['Txt']}"
393+
},
394+
"runAfter": {
395+
"Initialize_variable_-_object_array": [
396+
"Succeeded"
397+
]
398+
}
399+
}
400+
},
401+
```
402+
366403
## Next steps
367404

368405
* [Perform data operations](../logic-apps/logic-apps-perform-data-operations.md)

articles/logic-apps/logic-apps-perform-data-operations.md

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ services: logic-apps
55
ms.suite: integration
66
ms.reviewer: estfan, azla
77
ms.topic: how-to
8-
ms.date: 05/23/2023
8+
ms.date: 12/13/2023
99
# As a developer using Azure Logic Apps, I want to perform various data operations on various data types for my workflow in Azure Logic Apps.
1010
---
1111

@@ -1203,12 +1203,16 @@ If you used the Office 365 Outlook action, you get a result similar to the follo
12031203

12041204
## Select action
12051205

1206-
To create an array that contains JSON objects built from the values in an existing array, use the **Select** action. For example, you can create a JSON object for each value in an integer array by specifying the properties that each JSON object must have and mapping the values from the source array to those properties.
1207-
1208-
Although you can change the component JSON objects, the output array always has the same number of items as the source array. To use the output array from the **Select** action, subsequent actions must either accept arrays as input, or you might have to transform the output array into another compatible format.
1206+
By default, the **Select** action creates an array that contains JSON objects built from the values in an existing array. For example, you can create a JSON object for each value in an integer array by specifying the properties that each JSON object must have and mapping the values from the source array to those properties. Although you can change the component JSON objects, the output array always has the same number of items as the source array. To use the output array from the **Select** action, subsequent actions must either accept arrays as input, or you might have to transform the output array into another compatible format.
12091207

12101208
To try the **Select** action, follow these steps by using the workflow designer. Or, if you prefer working in the code view editor, you can copy the example **Select** and **Initialize variable** action definitions from this guide into your own logic app's underlying workflow definition: [Data operation code examples - Select](../logic-apps/logic-apps-data-operations-code-samples.md#select-action-example). For more information about this action in your underlying workflow definition, see [Select action](logic-apps-workflow-actions-triggers.md#select-action).
12111209

1210+
> [!TIP]
1211+
>
1212+
> For an example that creates create an array with strings or integers built from the values in a JSON object array,
1213+
> see the **Select** and **Initliaze variable** action definitions in
1214+
> [Data operation code examples - Select](../logic-apps/logic-apps-data-operations-code-samples.md#select-action-example).
1215+
12121216
### [Consumption](#tab/consumption)
12131217

12141218
1. In the [Azure portal](https://portal.azure.com), Visual Studio, or Visual Studio Code, open your logic app workflow in the designer.
246 Bytes
Loading

0 commit comments

Comments
 (0)