---
schema_version: "1"
id: e389ba00ce1a17b1f9e80f69a10d7a9b3f1249ab207b1b0e81a8b9433682179f
title: Process Arrays Using Loop Blocks (Managed Package)
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/xcloud/264-0-0/os_process_arrays_using_loop_blocks.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_process_arrays_using_loop_blocks.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: 347d7cb50fb1f08d1cea24688b833dbcd7e92610438f5b5044e43ae863c2c2f0
description: For the managed package runtime, a Loop Block iterates over the items in a data array, enabling the Actions within it to repeat for each item. For example, in ​Salesforce Industries Communications, Media, and Energy, without a Loop Block, adding four products to a cart would require running four separate Remote Actions. But one Remote Action within a Loop Block can add all four products.
products:
  - Omnistudio
release: "264"
---
# Process Arrays Using Loop Blocks (Managed Package)

For the managed package runtime, a Loop Block iterates over the items in a data array, enabling the Actions within it to repeat for each item. For example, in ​Salesforce Industries Communications, Media, and Energy, without a Loop Block, adding four products to a cart would require running four separate Remote Actions. But one Remote Action within a Loop Block can add all four products.

![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).

Loop Blocks are available in Spring '19 and later releases.

The array input to the Loop Block is processed so that each iteration receives only one item in the array. For example, suppose the array input looks like this:

```
{
  "Products": {
    "Ids": [
      {
        "Id": 1
      },
      {
        "Id": 2
      }
    ]
  }
}
```

Each iteration of the Loop Block would receive input that looks like this:

```
{
  "Products": {
    "Ids": {
      "Id": 1
    }
  }
}
```

The iteration input is the data to which Actions within the Loop Block have access.

![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

Nested Loop Blocks aren't supported. However, you can call one Integration Procedure with a Loop Block from another.

![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 For a Loop Block that calls an Omnistudio Data Mapper Transform, a list with more than 1000 items degrades performance. You can use a [paging strategy](https://help.salesforce.com/s/articleView?id=xcloud.os_page_through_sorted_data_using_offsets.htm&release=264.0.0&type=5 "For the managed package runtime, if an Omnistudio Data Mapper Extract is expected to retrieve a lot of records, you can use paging to retrieve a few at a time based on OFFSET values. For example, you can page through Contacts by last name.") to break up long lists.

To configure a Loop Block:

1. Drag a Loop Block into the structure panel.
2. In the Loop Block property field labeled **Loop List**, enter the name of a JSON node that contains an array of data. For example, entering Products:Ids provides a list of Ids to the Action. The JSON node name does not need to be entered with merge field syntax.
3. Add any Action that needs to iterate over the array and pass the full the path of the array to the action.
    
    For example, if the Loop List is set to an array named **Products:Ids** that contains key-value pairs of Ids, the full path in the action would be **Products:Ids:Id**.
    
    For more information on Actions, see [Integration Procedure Actions (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_integration_procedure_actions.htm&release=264.0.0&type=5 "For the managed package runtime, to compose an Integration Procedure, you add actions that run sequentially. These actions can set data values, perform functions, call Omnistudio Data Mappers, invoke Apex classes, send emails, invoke REST endpoints, run other Integration Procedures, and more.").
    
    ![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
    
    The Integration Procedure stops running and returns a response of `{ "Success": "False" }` if an Action that has **Fail on Step Error** checked fails.
4. Under the Loop Block property field labeled **Loop Output**, click **Add Key/Value Pair** to add Key-Value pairs to set the response. The value field uses merge field syntax, meaning the node name of the response set between two percentage signs, for example, `%ResponseData:Names%`.
5. (Optional) Add Conditional Logic to define when the Loop Block runs. For more information on Conditional Logic, see [Define Execution Logic Using Conditional Blocks (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_define_execution_logic_using_conditional_blocks.htm&release=264.0.0&type=5 "For the managed package runtime, a Conditional Block executes in its entirety if an expression is true, executes one of a set of mutually exclusive conditions defined in the steps it contains, or both.").
    
    For additional Loop Block examples, see [Integration Procedure Action for Integration Procedures (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_integration_procedure_action_for_integration_procedures.htm&release=264.0.0&type=5 "For the managed package runtime, the Integration Procedure Action runs a subordinate Integration Procedure."), [Enhance Performance Using Cache Blocks (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_enhance_performance_using_cache_blocks.htm&release=264.0.0&type=5 "For the managed package runtime, using a cache to store frequently accessed, infrequently updated data saves round trips to the database and improves performance. Use Cache Blocks if some parts of the Integration Procedure update data, or if you need different cached data to expire at different times. For example, current weather data changes more frequently than user session data."), and [Cache for Top-Level Integration Procedure Data (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_cache_for_top_level_integration_procedure_data.htm&release=264.0.0&type=5 "For the managed package runtime, using a cache to store frequently accessed, infrequently updated Integration Procedure data saves round trips to the database and improves performance. You can cache all the data for an Integration Procedure, as described here, or you can use a Cache Block to cache only part of it.").

- **[Loop Block Properties (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_loop_block_properties.htm&release=264.0.0&type=5)**  
    For the managed package runtime, these properties are unique to or function in a unique manner in Loop Blocks. A Loop Block iterates over the items in a data array, enabling the Actions within it to repeat for each item.
- **[Create a Loop Block Example that Retrieves Names (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_loop_block_example_that_retrieves_names.htm&release=264.0.0&type=5)**  
    For the managed package runtime, an Integration Procedure accepts last names and returns the full names of all Contacts having the specified last names.
- **[Create a Loop Block Example that Creates Contacts (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_loop_block_example_that_creates_contacts.htm&release=264.0.0&type=5)**  
    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.
- **[Create a Loop Block Example that Concatenates List Items (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_loop_block_example_that_concatenates_list_items.htm&release=264.0.0&type=5)**  
    For the managed package runtime, an Integration Procedure concatenates the values of items in a list. In this case, it creates an underscore-separated String of QuoteLineItem Ids.
- **[Create a Loop Block Example That Adds Values to List Items Using Conditions (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_loop_block_example_add_value_to_list_items_conditions.htm&release=264.0.0&type=5)**  
    For the managed package runtime, an Integration Procedure adds a dynamic value to each item in a list using conditions. Although dynamic in the list, the values are hard-coded in the Integration Procedure. Use this approach if you know or care about a specific set of possible values.
- **[Create a Loop Block Example That Adds Values to List Items Using VALUELOOKUP (Managed Package)](https://help.salesforce.com/s/articleView?id=xcloud.os_loop_block_example_add_value_to_list_items_valuelookup.htm&release=264.0.0&type=5)**  
    For the managed package runtime, an Integration Procedure adds a dynamic value to each item in a list using the VALUELOOKUP function. The values aren't hard-coded in the Integration Procedure. Use this approach if you don't know the set of possible values in the input.