# Data Record Loop Index

{% hint style="info" %}
**Block Information**

Available in: Page Flow and Cloud Flow

Toolbox Category: Data

Block Type: [Output](https://docs.zingy.ai/app-editor/block-anatomy#output-block)

Output Type: [*numeric*](https://docs.zingy.ai/app-editor/page-flow/references/value-types)
{% endhint %}

**`Data Record Loop Index`** is an [output block](https://docs.zingy.ai/app-editor/block-anatomy#output-block) that provides the [zero-based](https://en.wikipedia.org/wiki/Zero-based_numbering) index of the current iteration of the [Data Record Loop](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-record-loop) block, when used inside the *Tasks* [Flow Parameter](https://docs.zingy.ai/app-editor/block-anatomy#flow-parameters). The output is of type [*numeric*](https://docs.zingy.ai/app-editor/page-flow/references/value-types) and is compatible with [Value Parameters](https://docs.zingy.ai/app-editor/block-anatomy#value-parameters) of type [*numeric*](https://docs.zingy.ai/app-editor/page-flow/references/value-types) or of type [*any*](https://docs.zingy.ai/app-editor/page-flow/references/value-types).

<div align="left"><figure><img src="https://3401585094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmnBepgycwgisXr9ya1N4%2Fuploads%2FmSM9JtdmaKNqbMLNTR7x%2Fimage.png?alt=media&#x26;token=3e0bad46-0249-4b84-943c-6871456aba05" alt="" width="221"><figcaption><p>Data Record Loop Index block</p></figcaption></figure></div>

{% hint style="warning" %}
NOTE: This block will provide valid values when used inside the *Tasks* [Flow Parameter](https://docs.zingy.ai/app-editor/block-anatomy#flow-parameters) of the [Data Record Loop](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-record-loop) block.
{% endhint %}

***

## Usage Example

{% hint style="info" %}
**NOTE: Please refer to the prerequisite information shown** [**here**](https://docs.zingy.ai/app-editor/page-flow/references/prerequisite-for-data-examples) **before seeing the example.**&#x20;
{% endhint %}

The image below shows an example of the **`Data Record Loop Index`** block. This example incorporates the *Usage Example* function, as outlined in the [Database Reading Logic for examples section](https://docs.zingy.ai/app-editor/references/prerequisite-for-data-examples#database-reading-logic-for-examples) on the prerequisite information page mentioned above.

<figure><img src="https://3401585094-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmnBepgycwgisXr9ya1N4%2Fuploads%2FQx0njgBG4CqXNdPX5nMV%2Fimage.png?alt=media&#x26;token=fb12b976-2327-4cc2-93f6-0f1153ddadb6" alt=""><figcaption><p>Example of Data Record Loop Index block</p></figcaption></figure>

Here is a summary of the above example:

* The [Data Record Loop](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-record-loop) block is used with the *Customers* [Database Table](https://docs.zingy.ai/app-editor/data/database-tables) and the dataset name of *ds1* are as [Value Parameters](https://docs.zingy.ai/app-editor/block-anatomy#value-parameters) .
* For each iteration inside the *Tasks* [Flow Parameter](https://docs.zingy.ai/app-editor/block-anatomy#flow-parameters), we use the [Write Log Message](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/write-log-message) block to log the current iteration index combined with the customer's email address by accessing the *EmailAddress* field of each record.
* The **`Data Record Loop Index`** block is used to get the current iteration index.
* To access information about the record, we use the [Data Record Info](https://docs.zingy.ai/app-editor/page-flow/toolbox-blocks/data-record-info) block.

The result for the above example can be seen in the [browser's web console](https://developer.chrome.com/docs/devtools/console/), and a sample is shown below (Note the [zero-based](https://en.wikipedia.org/wiki/Zero-based_numbering) index):

```log
[LOG(info) 08/29/2023 14:40:12.682] Index:  0 Email: john.smith@example.com
[LOG(info) 08/29/2023 14:40:12.683] Index:  1 Email: jane.smith@example.com
[LOG(info) 08/29/2023 14:40:12.684] Index:  2 Email: max.mustermann@example.com
[LOG(info) 08/29/2023 14:40:12.684] Index:  3 Email: joe.bloggs@example.com
```
