Skip to content

Commit 754cdc8

Browse files
authored
Merge pull request #89523 from ecfan/tables
Add expression editor steps for table actions and other clarity edits
2 parents 7f3572a + b8b8a18 commit 754cdc8

9 files changed

+144
-68
lines changed

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

Lines changed: 144 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -172,55 +172,93 @@ If you prefer working in the code view editor, you can copy the example **Create
172172

173173
### Customize table format
174174

175-
By default, the **Columns** property is set to automatically create the table columns based on the array items.
176-
177-
To specify custom headers and values, follow these steps:
175+
By default, the **Columns** property is set to automatically create the table columns based on the array items. To specify custom headers and values, follow these steps:
178176

179177
1. Open the **Columns** list, and select **Custom**.
180178

181179
1. In the **Header** property, specify the custom header text to use instead.
182180

183-
1. In the **Key** property, specify the custom value to use instead.
181+
1. In the **Value** property, specify the custom value to use instead.
184182

185-
To reference and edit the values from the array, you can use the `@item()` function in the **Create CSV table** action's JSON definition.
183+
To return values from the array, you can use the [`item()` function](../logic-apps/workflow-definition-language-functions-reference.md#item) with the **Create CSV table** action. In a `For_each` loop, you can use the [`items()` function](../logic-apps/workflow-definition-language-functions-reference.md#items).
186184

187-
1. On the designer toolbar, select **Code view**.
185+
For example, suppose you want table columns that have only the property values and not the property names from an array. To return only these values, follow these steps for working in designer view or in code view. Here is the result that this example returns:
188186

189-
1. In the code editor, edit action's `inputs` section to customize the table output the way that you want.
187+
```text
188+
Apples,1
189+
Oranges,2
190+
```
190191

191-
This example returns only the column values and not the headers from the `columns` array by setting the `header` property to an empty value and dereferencing each `value` property:
192+
#### Work in designer view
192193

193-
```json
194-
"Create_CSV_table": {
195-
"inputs": {
196-
"columns": [
197-
{
198-
"header": "",
199-
"value": "@item()?['Description']"
200-
},
201-
{
202-
"header": "",
203-
"value": "@item()?['Product_ID']"
204-
}
205-
],
206-
"format": "CSV",
207-
"from": "@variables('myJSONArray')"
208-
}
209-
}
210-
```
194+
In the action, keep the **Header** column empty. On each row in the **Value** column, dereference each array property that you want. Each row under **Value** returns all the values for the specified array property and becomes a column in your table.
211195

212-
Here is the result that this example returns:
196+
1. Under **Value**, on each row that you want, click inside the edit box so that the dynamic content list appears.
213197

214-
```text
215-
Results from Create CSV table action:
198+
1. In the dynamic content list, select **Expression**.
216199

217-
Apples,1
218-
Oranges,2
219-
```
200+
1. In the expression editor, enter this expression that specifies the array property value that you want, and select **OK**.
201+
202+
`item()?['<array-property-name>']`
203+
204+
For example:
205+
206+
* `item()?['Description']`
207+
* `item()?['Product_ID']`
208+
209+
![Expression to dereference property](./media/logic-apps-perform-data-operations/csv-table-expression.png)
210+
211+
1. Repeat the previous steps for each array property that you want. When you're done, your action looks like this example:
212+
213+
![Finished expressions](./media/logic-apps-perform-data-operations/finished-csv-expression.png)
214+
215+
1. To resolve expressions into more descriptive versions, switch to code view and back to designer view, and then reopen the collapsed action:
216+
217+
The **Create CSV table** action now appears like this example:
218+
219+
!["Create CSV table" action with resolved expressions and no headers](./media/logic-apps-perform-data-operations/resolved-csv-expression.png)
220+
221+
#### Work in code view
222+
223+
In the action's JSON definition, within the `columns` array, set the `header` property to an empty string. For each `value` property, dereference each array property that you want.
224+
225+
1. On the designer toolbar, select **Code view**.
226+
227+
1. In the code editor, in the action's `columns` array, add the empty `header` property and this `value` expression for each column of array values that you want:
228+
229+
```json
230+
{
231+
"header": "",
232+
"value": "@item()?['<array-property-name>']"
233+
}
234+
```
235+
236+
For example:
237+
238+
```json
239+
"Create_CSV_table": {
240+
"inputs": {
241+
"columns": [
242+
{
243+
"header": "",
244+
"value": "@item()?['Description']"
245+
},
246+
{
247+
"header": "",
248+
"value": "@item()?['Product_ID']"
249+
}
250+
],
251+
"format": "CSV",
252+
"from": "@variables('myJSONArray')"
253+
}
254+
}
255+
```
220256

221-
In the designer, the **Create CSV table** action now appears this way:
257+
1. Switch back to designer view, and reopen the collapsed action.
222258

223-
!["Create CSV table" with no column headers](./media/logic-apps-perform-data-operations/create-csv-table-no-column-headers.png)
259+
The **Create CSV table** action now appears like this example, and the expressions have resolved to more descriptive versions:
260+
261+
!["Create CSV table" action with resolved expressions and no headers](./media/logic-apps-perform-data-operations/resolved-csv-expression.png)
224262

225263
For more information about this action in your underlying workflow definition, see the [Table action](../logic-apps/logic-apps-workflow-actions-triggers.md#table-action).
226264

@@ -287,55 +325,93 @@ If you prefer working in the code view editor, you can copy the example **Create
287325

288326
### Customize table format
289327

290-
By default, the **Columns** property is set to automatically create the table columns based on the array items.
291-
292-
To specify custom headers and values, follow these steps:
328+
By default, the **Columns** property is set to automatically create the table columns based on the array items. To specify custom headers and values, follow these steps:
293329

294330
1. Open the **Columns** list, and select **Custom**.
295331

296332
1. In the **Header** property, specify the custom header text to use instead.
297333

298-
1. In the **Key** property, specify the custom value to use instead.
334+
1. In the **Value** property, specify the custom value to use instead.
299335

300-
To reference and edit the values from the array, you can use the `@item()` function in the **Create HTML table** action's JSON definition.
336+
To return values from the array, you can use the [`item()` function](../logic-apps/workflow-definition-language-functions-reference.md#item) with the **Create HTML table** action. In a `For_each` loop, you can use the [`items()` function](../logic-apps/workflow-definition-language-functions-reference.md#items).
301337

302-
1. On the designer toolbar, select **Code view**.
338+
For example, suppose you want table columns that have only the property values and not the property names from an array. To return only these values, follow these steps for working in designer view or in code view. Here is the result that this example returns:
303339

304-
1. In the code editor, edit action's `inputs` section to customize the table output the way that you want.
340+
```text
341+
Apples,1
342+
Oranges,2
343+
```
305344

306-
This example returns only the column values and not the headers from the `columns` array by setting the `header` property to an empty value and dereferencing each `value` property:
345+
#### Work in designer view
307346

308-
```json
309-
"Create_HTML_table": {
310-
"inputs": {
311-
"columns": [
312-
{
313-
"header": "",
314-
"value": "@item()?['Description']"
315-
},
316-
{
317-
"header": "",
318-
"value": "@item()?['Product_ID']"
319-
}
320-
],
321-
"format": "HTML",
322-
"from": "@variables('myJSONArray')"
323-
}
324-
}
325-
```
347+
In the action, keep the **Header** column empty. On each row in the **Value** column, dereference each array property that you want. Each row under **Value** returns all the values for the specified property and becomes a column in your table.
326348

327-
Here is the result that this example returns:
349+
1. Under **Value**, on each row that you want, click inside the edit box so that the dynamic content list appears.
328350

329-
```text
330-
Results from Create HTML table action:
351+
1. In the dynamic content list, select **Expression**.
331352

332-
Apples 1
333-
Oranges 2
334-
```
353+
1. In the expression editor, enter this expression that specifies the array property value that you want, and select **OK**.
354+
355+
`item()?['<array-property-name>']`
356+
357+
For example:
358+
359+
* `item()?['Description']`
360+
* `item()?['Product_ID']`
361+
362+
![Expression to dereference property](./media/logic-apps-perform-data-operations/html-table-expression.png)
363+
364+
1. Repeat the previous steps for each array property that you want. When you're done, your action looks like this example:
365+
366+
![Finished expressions](./media/logic-apps-perform-data-operations/finished-html-expression.png)
367+
368+
1. To resolve expressions into more descriptive versions, switch to code view and back to designer view, and then reopen the collapsed action:
369+
370+
The **Create HTML table** action now appears like this example:
371+
372+
!["Create HTML table" action with resolved expressions and no headers](./media/logic-apps-perform-data-operations/resolved-html-expression.png)
373+
374+
#### Work in code view
375+
376+
In the action's JSON definition, within the `columns` array, set the `header` property to an empty string. For each `value` property, dereference each array property that you want.
377+
378+
1. On the designer toolbar, select **Code view**.
379+
380+
1. In the code editor, in the action's `columns` array, add the empty `header` property and this `value` expression for each column of array values that you want:
381+
382+
```json
383+
{
384+
"header": "",
385+
"value": "@item()?['<array-property-name>']"
386+
}
387+
```
388+
389+
For example:
390+
391+
```json
392+
"Create_HTML_table": {
393+
"inputs": {
394+
"columns": [
395+
{
396+
"header": "",
397+
"value": "@item()?['Description']"
398+
},
399+
{
400+
"header": "",
401+
"value": "@item()?['Product_ID']"
402+
}
403+
],
404+
"format": "HTML",
405+
"from": "@variables('myJSONArray')"
406+
}
407+
}
408+
```
409+
410+
1. Switch back to designer view, and reopen the collapsed action.
335411

336-
In the designer, the **Create HTML table** action now appears this way:
412+
The **Create HTML table** action now appears like this example, and the expressions have resolved to more descriptive versions:
337413

338-
!["Create HTML table" with no column headers](./media/logic-apps-perform-data-operations/create-html-table-no-column-headers.png)
414+
!["Create HTML table" action with resolved expressions and no headers](./media/logic-apps-perform-data-operations/resolved-html-expression.png)
339415

340416
For more information about this action in your underlying workflow definition, see the [Table action](../logic-apps/logic-apps-workflow-actions-triggers.md#table-action).
341417

23.3 KB
Loading
5.09 KB
Loading
5.1 KB
Loading
23.2 KB
Loading
11.4 KB
Loading
11.4 KB
Loading

0 commit comments

Comments
 (0)