--- title: "Simple Loops: For Loop Snippet" slug: "simple-loops-for-loop-snippet" updated: 2025-09-26T06:59:05Z published: 2025-09-26T06:59:05Z canonical: "docs.unqork.io/simple-loops-for-loop-snippet" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.unqork.io/llms.txt > Use this file to discover all available pages before exploring further. # Simple Loops: For Loop Snippet ## Overview Performing the same action on your data over and over again is a time sink. Using a loop for your data makes this process more efficient. A loop is a repeating process that's based on a condition. This might be an API call, a set number of iterations, or another action. The For Loop is one of the Simple Loop snippets. A for loop makes it easy to perform a repeating task on multiple objects in a data set. Generally, you'll use a for loop when you know how many times the loop must run. In this snippet, it's once per row of data. ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/For_Loop_GIF.gif?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) ### Similar Loops There are many loop templates that serve different purposes. Here are the loops compared: - **For Loop**: Processes data based on the number of data rows. - **While Loop**: Processes data based on a data condition. This loop confirms the condition is true before running the action. - **Do While Loop**: Processes data based on a data condition. This loop confirms the condition is true after running the action. - **Batch Loop**: Processes arrays based on either the number of data rows or condition. Your snippet doesn't show anything in Express View except the Start Loop button. Because the loop happens behind the scenes, you only see activity in the DevTools Console. However, you can see what your data is doing when you run an angular command. Here's how the snippet looks in Express View, with a sneak peek at the DevTools Console: ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/For_Loop_03.jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) And here's how the snippet looks in the Module Builder: ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/For_Loop_04.jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) ## Adding the Snippet To add the Simple For Loop snippet to your module: 1. In the left sidebar of the Module Builder, click **Snippet****s**. 2. Enter **For Loop** in the search bar. 3. Drag and drop the **For Loop** snippet onto your canvas. 4. **Save** your module. ## How the Snippet Works This snippet relies heavily on the Data Workflow component. In Express View, the only component you see is the Start Loop button. This triggers the initializer to begin your Data Workflow. The Data Workflow has two inputs. One from the dtIpnutData component to get the data size. And the other from the iterator Hidden component that determines how many times the loop performs. From there, the Data Workflow takes these actions: - **Get Current Row**: Looks at the current row of data (stored in the currentRow Hidden component). - **Increase Iterator**: Increases the iterator by 1 to continue the loop. - **Call Plugin**: Calls the pluginAction Plug-In component for the action you want to take with your data. - **End Loop**: Ends the loop when there are no more iterations. ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/For_Loop_06.jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) Once complete, the initEndLoop Initializer component stops the workflow. ## Configuring the Snippet Out of the box, the For Loop snippet has the basic logic components ready to go. For this example, you only need to adjust the data table and plug-in. Let's say you have a list of email addresses of people who enrolled with your company, and you want to send them a welcome email. Here's how it works. > [!NOTE] > This example uses the SendGrid service. To learn more, search **SendGrid Single Email Module Integration Template** in our In-Product Help. ### Update the Data Table Component To get started, enter the email addresses in the Data Table. 1. Hover over the exampleArrayToProcess Data Table component. A 5-button toolbar displays above the component on hover-over. 2. Click the ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/AppBuildButton_Settings(36).jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) (**Settings**) button to open the Configuration window. 3. In the data table, enter: | id | name | email | | --- | --- | --- | | 1 | Bruce | bruce@wayneenterprises.com | | 2 | Clark | clark@dailybugle.com | | 3 | Wally | wally@yahoo.com | ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/For_Loop_01(1).jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) 4. Click **Save**. ### Update the Plug-In Component The automatic email information goes in the pluginAction Plug-In. This example uses SendGrid to get the email information. 1. Hover over the exampleArrayToProcess Data Table component. A 5-button toolbar displays above the component on hover-over. 2. Click the ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/AppBuildButton_Settings(36).jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) (**Settings**) button to open the Configuration window. 3. Select **External** as the **Service Type**. 4. Select **SendGrid** from the **External Services** drop-down. 5. Enter mail/send at the end of the **Data Source URL**. 6. Select **Post** as the **Request Type**. 7. In the **Inputs** table, enter: | Property ID | Mapping | | --- | --- | | currentRow['email'] | personalizations[0].to[0].email | | 'This is a test email.' | content[0].value | | hiddenFromEmail | from.email | | 'Hello Subject' | subject | | 'text/html' | content[0].type | > [!NOTE] > If the Required boxes are selected, clear all Required checkboxes. ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/For_Loop_02(1).jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) 8. Click **Save**. When you click **Start Loop** in Express View, everyone in your Data Table receives an email. In the DevTools Console, you'll see the rows of data and the iterator that counts your data: ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/For_Loop_05.jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) ## Removing the Snippet If you find you no longer need the For Loop feature in your module, you can remove it. To remove the For Loop snippet: 1. In the Module Builder, hover over the panelSimpleForLoopSnippet Panel component. A 5-button toolbar displays above the component on hover-over. 2. Using the toolbar, click the ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/AppBuildButton_Remove(27).jpg?sv=2026-02-06&spr=https&st=2026-11-09T03%3A51%3A15Z&se=2026-11-09T04%3A51%3A15Z&sr=c&sp=r&sig=CpLZaF%2FJkZNn2q6psQlU%2BvQNkZRXm%2FlCHQzN0UAxjOI%3D) (**Remove**) button. 3. Save your module.