---
schema_version: "1"
id: 6494a736a226e49a05e51affe4cb6c5abe66ae064e4cb35cf6929942625874a1
title: Create a Loop Block Example that Creates Contacts (Managed Package)
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_create_a_loop_block_example_that_creates_contacts.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_loop_block_example_that_creates_contacts.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 31ba605b409e872a1ca2d18d697ea9e7352e191bcd565ba29980ac591639db9e
description: For the managed package runtime, an Integration Procedure accepts an Account Id and an array of first and last names and creates new Contacts for the specified Account. It also includes a step that deletes these Contacts, which you can optionally disable.
products:
  - Omnistudio
release: "264"
---
# Create a Loop Block Example that Creates Contacts (Managed Package)

For the managed package runtime, an Integration Procedure accepts an Account Id and an array of first and last names and creates new Contacts for the specified Account. It also includes a step that deletes these Contacts, which you can optionally disable.

![Managed Package app icon](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/resources-global/_corporate/images/managedpackageicon.png) This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see [Omnistudio Help](https://help.salesforce.com/s/articleView?id=xcloud.os_omnistudio_standard.htm&language=en_US).

To download a data pack of this example for Omnistudio for Managed Packages, click [here](https://volt.my.salesforce.com/sfc/p/o0000000IKm8/a/3m0000005uJJ/S9Hcylna8pOW1bomKVdBqNaFACq2L9qjsv9GawF6MQo).

![Note](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/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).

The Integration Procedure has these components:

- An optional Set Values component, named SetValues1
- A Loop Block component, named LoopBlock1
- A Data Mapper Post Action component within the Loop Block, named CreateContact
- A Data Mapper Load that creates a new Contact for an existing Account, named NewContactForAccount
- A Delete Action component within the Loop Block, named DeleteContact
- A Response Action, named ResponseAction1

The Structure panel looks like this:

![The contents of the Structure panel are listed in the preceding text.](https://sf-zdocs-cdn-prod.zoominsoftware.com/tdta-xcloud-omnistudio_for_managed_packages-264-0-0-production-enus/aa2554ec-624a-4ee6-8da4-6435670e6e62/omnistudio_for_managed_packages/images/iploopblock2.png)

To build this Integration Procedure:

1. From the Vlocity Integration Procedures tab, click **New**.
2. Provide a unique **Integration Procedure Name**, a **Type** that can be a category, and a unique **SubType**, then click **Save**. You only have to save this one time.
3. Drag a Loop Block into the Structure panel and give it the following settings:
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
            <colgroup>
              <col>
              <col>
            </colgroup>
            <thead class="slds-text-title_caps ">
              <tr class="">
                <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d150320e160">
                  <p style="margin-bottom:0;">Property</p>
                </th>
                <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d150320e166">
                  <p style="margin-bottom:0;">Description</p>
                </th>
              </tr>
            </thead>
            <tbody>
              <tr class="">
                <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e160 ">
                  <p style="margin-bottom:0;">Loop List</p>
                </td>

                <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e166 ">
                  <p style="margin-bottom:0;">Set this value to <code>Contacts</code>.</p>
                </td>

              </tr>
              <tr class="">
                <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e160 ">
                  <p style="margin-bottom:0;">Additional Loop Output</p>
                </td>

                <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e166 ">
                  <p style="margin-bottom:0;">Set the Key to <code>CreateContact</code> and the Value to <code>%CreateContact%</code> to return all iterations of data generated by the Data Mapper Post Action component.</p>
                </td>

              </tr>
            </tbody>
          </table>
4. To create the Data Mapper Load that the Data Mapper Post Action calls, create the second example in [Omnistudio Data Mapper Load Examples (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_dataraptor_load_examples.htm&release=264.0.0&type=5 "For the managed package runtime, Data Mapper Load examples demonstrate formulas and object relationships, and working with attributes.") and name it NewContactForAccount.
5. Drag a Data Mapper Post Action component within the Loop Block and give it the following settings:
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
            <colgroup>
              <col>
              <col>
            </colgroup>
            <thead class="slds-text-title_caps ">
              <tr class="">
                <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d150320e250">
                  <p style="margin-bottom:0;">Property</p>
                </th>
                <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d150320e256">
                  <p style="margin-bottom:0;">Description</p>
                </th>
              </tr>
            </thead>
            <tbody>
              <tr class="">
                <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e250 ">
                  <p style="margin-bottom:0;">Name</p>
                </td>

                <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e256 ">
                  <p style="margin-bottom:0;">Set this value to <code>CreateContact</code>.</p>
                </td>

              </tr>
              <tr class="">
                <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e250 ">
                  <p style="margin-bottom:0;">Data Mapper Interface</p>
                </td>

                <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e256 ">
                  <p style="margin-bottom:0;">Set this value to <code>NewContactForAccount</code>.</p>
                </td>

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

                <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e256 ">
                  <p>Set the first Key to <code>AccountId</code> and its value to <code>%AccountId%</code>.</p>
                  <p style="margin-bottom:0;">Set the second Key to <code>Name</code> and its value to <code>%Contacts:Name%</code>.</p>
                </td>

              </tr>
            </tbody>
          </table>
6. Drag a Delete Action component within the Loop Block and give it the following settings:
    
    <table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
            <colgroup>
              <col>
              <col>
            </colgroup>
            <thead class="slds-text-title_caps ">
              <tr class="">
                <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d150320e355">
                  <p style="margin-bottom:0;">Property</p>
                </th>
                <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d150320e361">
                  <p style="margin-bottom:0;">Description</p>
                </th>
              </tr>
            </thead>
            <tbody>
              <tr class="">
                <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e355 ">
                  <p style="margin-bottom:0;">Name</p>
                </td>

                <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e361 ">
                  <p style="margin-bottom:0;">Set this value to <code>DeleteContact</code>.</p>
                </td>

              </tr>
              <tr class="">
                <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e355 ">
                  <p>Delete SObject:</p>
                  <p style="margin-bottom:0;">Type</p>
                </td>

                <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e361 ">
                  <p style="margin-bottom:0;">Set this value to <code>Contact</code>.</p>
                </td>

              </tr>
              <tr class="">
                <td data-label="Property" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e355 ">
                  <p>Delete SObject:</p>
                  <p style="margin-bottom:0;">Path To Id</p>
                </td>

                <td data-label="Description" class="slds-cell-wrap" style="vertical-align:top;" headers="d150320e361 ">
                  <p style="margin-bottom:0;">Set this value to <code>%CreateContact:Contact_1:Id%</code>.</p>
                </td>

              </tr>
            </tbody>
          </table>
7. Drag a Response Action below the Loop Block and check **Return Full Data JSON**.
8. Go to the Preview tab and click **Edit as JSON**.
9. Copy this JSON data and paste it into the Input Parameters panel, substituting names of your choice:
    
    ```
    {
        "AccountId": "0016100001BKL4uAAH",
        "Contacts": [
            {
                "Name": {
                    "First": "John",
                    "Last": "Doe"
                }
            },
            {
                "Name": {
                    "First": "June",
                    "Last": "Doe"
                }
            }
        ]
    }
    ```
10. Click **Execute**. If you built the Integration Procedure correctly, the output looks something like this:
    
    ```
    {
      "response": {},
      "ResponseAction1Status": true,
      "LoopBlock1": [
        {
          "CreateContact": {
            "ActualTime": 793,
            "CpuTime": 537,
            "Contact_2": [
              {
                "UpsertSuccess": true,
                "Id": "0034N00001qh5hVQAQ",
                "AccountId": "0016100001BKL4uAAH",
                "LastName": "Doe",
                "FirstName": "John"
              }
            ],
            "Account_1": [
              {
                "UpsertSuccess": true,
                "Id": "0016100001BKL4uAAH"
              }
            ],
            "error": "OK",
            "responseType": "SObject"
          },
          "DeleteContactStatus": true,
          "CreateContactStatus": true,
          "LoopBlockIterationStatus": true,
          "LoopBlockIterationIndex": 1
        },
        {
          "CreateContact": {
            "ActualTime": 1262,
            "CpuTime": 799,
            "Contact_2": [
              {
                "UpsertSuccess": true,
                "Id": "0034N00001qh5hWQAQ",
                "AccountId": "0016100001BKL4uAAH",
                "LastName": "Doe",
                "FirstName": "June"
              }
            ],
            "Account_1": [
              {
                "UpsertSuccess": true,
                "Id": "0016100001BKL4uAAH"
              }
            ],
            "error": "OK",
            "responseType": "SObject"
          },
          "DeleteContactStatus": true,
          "CreateContactStatus": true,
          "LoopBlockIterationStatus": true,
          "LoopBlockIterationIndex": 2
        }
      ],
      "LoopBlock1Status": true,
      "SetValues1": {
        "Contacts": [
          {
            "Name": {
              "Last": "Doe",
              "First": "John"
            }
          },
          {
            "Name": {
              "Last": "Doe",
              "First": "June"
            }
          }
        ],
        "AccountId": "0016100001BKL4uAAH"
      },
      "SetValues1Status": true,
      "options": {
        "chainable": false
      }
    }
    ```
    
    To correct a component, click it in the Structure panel and edit its properties.