You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/logic-apps/logic-apps-control-flow-loops.md
+69-73Lines changed: 69 additions & 73 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,9 +32,7 @@ Azure Logic Apps includes the following loop actions that you can use in your wo
32
32
33
33
## For each
34
34
35
-
The **For each** action repeats one or more actions on each array item and works only on arrays.
36
-
37
-
Here are some considerations to remember when you use a **For each** action:
35
+
The **For each** action repeats one or more actions on each array item and works only on arrays. The following list contains some considerations for when you want to use a **For each** action:
38
36
39
37
* The **For each** action can process a limited number of array items. For this limit, see [Concurrency, looping, and debatching limits](../logic-apps/logic-apps-limits-and-config.md#looping-debatching-limits).
40
38
@@ -144,7 +142,7 @@ Follow the steps based on whether you create a Consumption or Standard logic app
144
142
145
143
## For each action definition (JSON)
146
144
147
-
If you're working in your workflow's code view, you can define the `Foreach` loop in your workflow's JSON definition instead, for example:
145
+
If you're working in code view, you can define the `For_each` action in your workflow's JSON definition, for example:
148
146
149
147
```json
150
148
"actions": {
@@ -204,10 +202,9 @@ By default, the iterations in a **For each** loop run at the same time in parall
204
202
205
203
---
206
204
207
-
###For each action definition (JSON): Run sequentially
205
+
## For each action definition (JSON): Run sequentially
208
206
209
-
If you're working with your workflow's JSON definition, you can use the `Sequential` option by adding the
210
-
`operationOptions` parameter, for example:
207
+
If you're working in code view with the `For_each` action in your workflow's JSON definition, you can use the `Sequential` option by adding the `operationOptions` parameter, for example:
211
208
212
209
```json
213
210
"actions": {
@@ -227,113 +224,112 @@ If you're working with your workflow's JSON definition, you can use the `Sequent
227
224
228
225
## Until
229
226
230
-
To run and repeat actions until a condition gets met or a state changes, put those actions in an "Until" loop. Your logic app first runs any and all actions inside the loop, and then checks the condition or state. If the condition is met, the loop stops. Otherwise, the loop repeats. For the default and maximum limits on the number of "Until" loops that a logic app run can have, see [Concurrency, looping, and debatching limits](../logic-apps/logic-apps-limits-and-config.md#looping-debatching-limits).
227
+
The **Until** action runs and repeats one or more actions until the required specified condition is met. If the condition is met, the loop stops. Otherwise, the loop repeats. For the default and maximum limits on the number of **Until** actions or iterations that a workflow can have, see [Concurrency, looping, and debatching limits](logic-apps-limits-and-config.md#looping-debatching-limits).
231
228
232
-
Here are some common scenarios where you can use an "Until" loop:
229
+
The following list contains some common scenarios where you can use an **Until** action:
233
230
234
231
* Call an endpoint until you get the response you want.
235
232
236
-
* Create a record in a database. Wait until a specific field in that record gets approved. Continue processing.
233
+
* Create a record in a database. Wait until a specific field in that record gets approved. Continue processing.
237
234
238
-
Starting at 8:00 AM each day, this example logic app increments a variable until the variable's value equals 10. The logic app then sends an email that confirms the current value.
235
+
In the following example workflow, starting at 8:00 AM each day, the **Until** action increments a variable until the variable's value equals 10. The workflow then sends an email that confirms the current value.
239
236
240
237
> [!NOTE]
241
-
> These steps use Office 365 Outlook, but you can
242
-
> use any email provider that Logic Apps supports.
243
-
> [Check the connectors list here](/connectors/).
244
-
> If you use another email account, the general steps stay the same,
245
-
> but your UI might look slightly different.
238
+
>
239
+
> This example uses Office 365 Outlook, but you can use [any email provider that Azure Logic Apps supports](/connectors/).
240
+
> If you use another email account, the general steps stay the same, but your UI might look slightly different.
246
241
247
-
1. Create a blank logic app. In Logic App Designer,
248
-
under the search box, choose **All**. Search for "recurrence".
249
-
From the triggers list, select this trigger: **Recurrence - Schedule**
1. In the [Azure portal](https://portal.azure.com), create a Consumption logic app resource with a blank workflow.
252
245
253
-
1. Specify when the trigger fires by setting the interval, frequency,
254
-
and hour of the day. To set the hour, choose **Show advanced options**.
246
+
1. In the designer, [follow these general steps to add the **Recurrence** built-in trigger named **Schedule** to your workflow](create-workflow-with-trigger-or-action.md?tabs=consumption#add-trigger).
255
247
256
-

248
+
1. In the **Recurrence** trigger, specify the interval, frequency, and hour of the day for the trigger to fire.
257
249
258
250
| Property | Value |
259
-
|--------|-----|
260
-
|**Interval**| 1 |
251
+
|----------|-------|
252
+
|**Interval**| 1 |
261
253
|**Frequency**| Day |
262
254
|**At these hours**| 8 |
263
-
|||
264
255
265
-
1. Under the trigger, choose **New step**.
266
-
Search for "variables", and select this action:
267
-
**Initialize variable - Variables**
256
+
To add the **At these hours** parameter, open the **Add new parameter** list, and select **At these hours**, which is available only after you set **Frequency** to **Day**.
257
+
258
+

259
+
260
+
When you're done, the trigger information box looks like the following example:

270
263
271
-
1.Set up your variable with these values:
264
+
1.Under the trigger, [follow these general steps to add the **Variables** built-in action named **Initialize variable** to your workflow](create-workflow-with-trigger-or-action.md?tabs=consumption#add-action).
1. In the **Initialize variable** action, provide the following values:
274
267
275
268
| Property | Value | Description |
276
-
| -------- | ----- | ----------- |
277
-
|**Name**| Limit | Your variable's name |
278
-
|**Type**| Integer | Your variable's data type |
279
-
|**Value**| 0 | Your variable's starting value |
280
-
||||
269
+
|----------|-------|-------------|
270
+
|**Name**| Limit | Your variable's name |
271
+
|**Type**| Integer | Your variable's data type |
272
+
|**Value**| 0 | Your variable's starting value |
281
273
282
-
1. Under the **Initialize variable** action, choose **New step**.
274
+

283
275
284
-
1. Under the search box, choose **All**. Search for "until",
285
-
and select this action: **Until - Control**
276
+
1. Under the **Initialize variable** action, [follow these general steps to add the **Control** built-in action named **Until** to your workflow](create-workflow-with-trigger-or-action.md?tabs=consumption#add-action).
1. In the **Until** action, provide the following values to set up the stop condition for the loop.
288
279
289
-
1. Build the loop's exit condition by selecting
290
-
the **Limit** variable and the **is equal** operator.
291
-
Enter **10** as the comparison value.
280
+
1. Select inside the leftmost box named **Choose a value**, which automatically opens the dynamic content list.
292
281
293
-

282
+
1. From the list, under **Variables**, select the variable named **Limit**.
294
283
295
-
1.Inside the loop, choose **Add an action**.
284
+
1.From the middle operator list, select the **is equal** operator.
296
285
297
-
1. Under the search box, choose **All**. Search for "variables",
298
-
and select this action: **Increment variable - Variables**
286
+
1. In the rightmost box named **Choose a value**, enter **10** as the comparison value.
299
287
300
-

288
+

301
289
302
-
1. For **Name**, select the **Limit** variable. For **Value**,
303
-
enter "1".
290
+
1. Inside the **Until** action, select **Add an action**.
304
291
305
-

292
+
1. In the **Choose an operation** search box, [follow these general steps to add the **Variables** built-in action named **Increment variable** to the **Until** action](create-workflow-with-trigger-or-action.md?tabs=consumption#add-action).
306
293
307
-
1.Outside and under the loop, choose **New step**.
294
+
1.In the **Increment variable** action, provide the following values to increment the **Limit** variable's value by 1:
308
295
309
-
1. Under the search box, choose **All**.
310
-
Find and add an action that sends email,
311
-
for example:
296
+
| Property | Value |
297
+
|----------|-------|
298
+
|**Name**| Select the **Limit** variable. |
299
+
|**Value**|**1**|
300
+
301
+

312
302
313
-

303
+
1. Outside and under the loop, [follow these general steps to add an action that sends email](create-workflow-with-trigger-or-action.md?tabs=consumption#add-action).
314
304
315
-
1. If prompted, sign in to your email account.
305
+
This example continues with the **Office 365 Outlook** action named **Send an email**.
316
306
317
-
1. Set the email action's properties. Add the **Limit**
318
-
variable to the subject. That way, you can confirm the
319
-
variable's current value meets your specified condition,
320
-
for example:
307
+
1. In the email action, provide the following values:
308
+
309
+
| Property | Value | Description |
310
+
|----------|-------|-------------|
311
+
|**To**| <*email-address\@domain*> | The recipient's email address. For testing, use your own email address. |
312
+
|**Subject**|**Current value for "Limit" variable is:****Limit**| The email subject. For this example, make sure that you include the **Limit** variable to confirm that the current value meets your specified condition: <br><br>1. Select inside the **Subject** box so that the dynamic content list appears. <br><br>2. In the dynamic content list, next to the **Variables** section header, select **See more**. <br><br>3. Select **Lmiit**. |
313
+
|**Body**| <*email-content*> | The email message content that you want to send. For this example, enter whatever text you want. |
314
+
315
+
When you're done, your email action looks similar to the following example:
316
+
317
+

318
+
319
+
1. Save your workflow.
320
+
321
+
### [Standard](#tab/standard)
322
+
323
+
---
321
324
322
-

325
+
### Test your workflow
323
326
324
-
| Property | Value | Description |
325
-
| -------- | ----- | ----------- |
326
-
|**To**|*\<email-address\@domain>*| The recipient's email address. For testing, use your own email address. |
327
-
|**Subject**| Current value for "Limit" is **Limit**| Specify the email subject. For this example, make sure that you include the **Limit** variable. |
328
-
|**Body**| <*email-content*> | Specify the email message content you want to send. For this example, enter whatever text you like. |
329
-
||||
327
+
1. To manually test your logic app, on the designer toolbar, select **Run Trigger** > **Run**.
330
328
331
-
1. Save your logic app. To manually test your logic app,
332
-
on the designer toolbar, choose **Run**.
333
329
334
-
After your logic starts running, you get an email with the content that you specified:
330
+
After your workflow starts running, you get an email with the content that you specified:
0 commit comments