The "Continue" Keyword Finally Comes to AL — 3 Practical Examples (BC 2025 Wave 1)
The continue keyword in AL for loops (for, while, repeat): skips the current iteration and moves to the next without ending the loop. Covers the difference from break, with three code examples: even numbers, sales invoice lines with customer emails, and a Microsoft IRS forms extension.
- Introduction to the continue keyword
- Distinguishing break and continue
- Example 1 - simple for loop with even numbers
- Example 2 - sales invoice lines and customer emails
- Example 3 - Microsoft IRS forms extension
- Summary and closing remarks
Overview
The video explains the new continue keyword in AL and how it differs from break. Break ends the loop, while continue jumps to the end of the current iteration and goes on with the next one. The presenter notes that the examples are made up, except one that comes from a Microsoft extension.
Three examples are shown: a simple for loop that skips even numbers, a loop over sales invoice lines tied to customer emails, and code in the Microsoft IRS forms extension (table 1099 form do header and codeunit Coordinate IRS 1099 send email). The presenter says continue is optional, so it is not a breaking change, and that the code could be restructured to avoid it. It can also save time compared with refactoring a whole function.
Key points
- continue is a new AL keyword in Business Central 2025 wave 1, used inside for, while and repeat loops.
- break ends the loop and runs the next statement after it; continue skips only the current iteration and moves to the next one.
- In the first example, a for loop from 1 to 10 uses the mod operator to find even numbers and skips them with continue.
- The second example (pseudo code) loops posted sales invoice lines from the last 30 days. It uses continue to skip customers already stored in a temporary emailed-customer table, so each customer gets one thank-you email.
- The third example is Microsoft code in the IRS Forms extension: while looping 1099 form headers, if the vendor cannot be found it logs an error and uses continue to move to the next record.
- Code can always be restructured to avoid continue, but the speaker suggests using it instead of spending time refactoring a whole loop or function.
Features
| Feature | Status | At |
|---|---|---|
| continue keyword in AL | status not stated, demoed | 0:11 |
AL objects mentioned
As heard in the captions. A name that matches one object page by exact type and name links to it; the others stay as named.
Not found in BC28-30: table “1099 form do header”, codeunit “Coordinate IRS 1099 send email”.
Quotes
- 0:39 “we need to distinguish between what break does and what continue does.”
- 0:53 “The break will um will terminate the loop. We will go to the next statement in the code after the loop.”
- 2:29 “we test if the number is an even number and if it’s an even number we skip it”
- 3:08 “continue which means don’t get here but rather here at the end and increment i to three”
- 8:14 “instead of spending the time to refactor all this function”
Disclaimers in the video
- 1:23 other: They are all made up examples, nothing from uh my work uh daily work. Um so um and one example is from Microsoft
