---
schema_version: "1"
id: c7c963bfcb0756a7cd67a0a5ce8b8a53985d297f47d1cc563b89ac2bd5782e2d
title: Create Contacts by Using a Loop Block
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_create_contacts_loop_block.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_create_contacts_loop_block.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 994a62c6a266096a8bca7515679eac8a96696c6a9ad9d96daf37be46e1041119
description: Use a Loop Block to iterate over a list provided in the input JSON, adding a Contact object for each element in the list.
products:
  - Omnistudio
release: "264"
---
# Create Contacts by Using a Loop Block

Use a Loop Block to iterate over a list provided in the input JSON, adding a Contact object for each element in the list.

For this example, assume the input JSON contains an Account Id and an array of first and last names, like the snippet below.

```json
{
    "AccountId": "0016100001BKL4uAAH",
    "Contacts": [
        {
            "Name": {
                "First": "John",
                "Last": "Doe"
            }
        },
        {
            "Name": {
                "First": "June",
                "Last": "Doe"
            }
        }
    ]
}
```

To create a contact, you can use a Data Mapper Load. When the script invokes the Data Mapper Load, the Data JSON is sent as input, so the Data Mapper Load can refer directly to the nodes in the input JSON.

After you create the Data Mapper Load, create a Data Mapper Post Action with properties similar to the properties in the table.

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small " summary="Data Mapper Post Action Properties">
      <caption>Data Mapper Post Action Properties</caption>
      <colgroup>
        <col style="width:50%">
        <col style="width:50%">
      </colgroup>
      <thead class="slds-text-title_caps ">
        <tr class="">
          <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d59944e51">Property</th>
          <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d59944e54">Description</th>
        </tr>
      </thead>
      <tbody>
        <tr class="">
          <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d59944e51 ">Data Mapper Interface</td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d59944e54 ">The name of the Data Mapper Load</td>

        </tr>
        <tr class="">
          <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d59944e51 ">Additional Input</td>

          <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d59944e54 ">
            <ul>
              <li> Key: <code>AccountId</code>
              </li>

              <li> Value: <code>%AccountId%</code>
              </li>

              <li> Key: <code>Name</code>
              </li>

              <li>Value: <code>%Contacts:Name%</code></li>

            </ul>
          </td>

        </tr>
      </tbody>
    </table>

This passes the first and last name of each contact, along with the AccountId, to the Data Mapper Load on each execution. You can also include more fields, such as phone numbers and email addresses.

Finally, you can create a Loop block to execute the Data Mapper Post Action for every contact. Use the name of the list of contacts for the Loop List parameter. For example, from the input JSON above, the Loop List would be `Contacts`. You can use the Additional Output parameter to pass along the execution output from each iteration of the Data Mapper Post Action. For example, if you named the Data Mapper Post Action `CreateContact` then for the Additional Output key and value you can use `CreateContact` and `%CreateContact%`, respectively.

Data Mapper Post Action output, which can be viewed in the Debug log on the Preview tab, allows other steps in the Integration Procedure to access and use the IDs and other details of the processed sObjects.

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio-264-0-0-production-enus/f526eaa8-ae05-487a-8944-4bb99b0b78ac/images/icon_note.png)

Note Using an Omnistudio Data Mapper Post action in a Loop Block can sometimes reach the limit of 150 DML statements. See [Execution Governors and Limits](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_gov_limits.htm).