--- title: "Simple Loops: While Loop Snippet" slug: "simple-loops-while-loop-snippet" updated: 2025-09-26T06:57:07Z published: 2025-09-26T06:57:07Z canonical: "docs.unqork.io/simple-loops-while-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: While 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 While Loop is one of the Simple Loop snippets. A while loop is controlled by a condition you set. Unlike a do while loop, it verifies the condition *before* the action. For example, if you have a list of submissions in real time, the loop can detect when the submissions stop, and then end the loop. ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/While_Loop_GIF.gif?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%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. 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/While_Loop_1.jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%3D) And here's how the snippet looks in the Module Builder: ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/While_Loop_02.jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%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 **While Loop** in the search bar. 3. Drag and drop the **While Loop** snippet onto your canvas. 4. **Save** your module. ## How the Snippet Works Like other loops, 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 uses your data from the input Hidden component to perform these actions: - **userNumber**: Looks at the data (stored in the input Hidden component). - **Update Input**: Observes the condition that starts 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 the condition stops being met. ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/While_Loop_03.jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%3D) Once complete, the initEndLoop Initializer component stops the workflow. ## Configuring the Snippet Out of the box, the While Loop snippet has the basic logic components ready to go. All you need to do is connect your data and adjust the pluginAction component. Let's say you're capturing email addresses of people who enrolled with your company, and you want to send them a welcome email using SendGrid. 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. ### Add a Data Table Component This example uses a Data Table to get input information. To get started, enter the email addresses in the Data Table. These act as the condition that starts your loop. 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(37).jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%3D) (**Settings**) button to open the Configuration window. 3. Enter dtInputData in the **Label** and **Property Name** fields. 4. In the 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(2).jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%3D) 5. 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(37).jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%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(2).jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%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: ![](https://cdn.us.document360.io/15548f06-2fba-434c-b0c1-5df88317dbd7/Images/Documentation/While_Loop_04(1).jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%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 While 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(28).jpg?sv=2026-02-06&spr=https&st=2026-11-07T17%3A57%3A42Z&se=2026-11-07T18%3A57%3A42Z&sr=c&sp=r&sig=iN9G2rh8Hpx9rtQEo5ThQLF6%2FhP5VTMZwmkAxohoFvI%3D) (**Remove**) button. 3. Save your module.