---
schema_version: "1"
id: fa68dc23f06e927ec11f7947e057c3b7a789d5e3724783f176a59e6f79a9fa7b
title: Create a Try-Catch Block Example (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_try_catch_block_example.md
canonical_url: https://help.salesforce.com/s/articleView?id=xcloud.os_create_a_try_catch_block_example.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: eedfd815e784b52b7523542340d2cf34a1044dd7a486cfd7910431b5c9342126
description: For the managed package runtime, an Integration Procedure creates and deletes a Contact with the specified LastName and returns an error message if the LastName is blank.
products:
  - Omnistudio
release: "264"
---
# Create a Try-Catch Block Example (Managed Package)

For the managed package runtime, an Integration Procedure creates and deletes a Contact with the specified LastName and returns an error message if the LastName is blank.

![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/3m0000005uI6/Y_49oasLW1pKSNYxAa9TNU4kbNYXNnJ8vcdqDzYA5Rk).

The Integration Procedure has these components:

- A Try-Catch Block, named TryCatchBlock1
- An Omnistudio Data Mapper Post Action, named DRPostAction1
- A Delete Action, named DeleteAction1
- 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/iptrycatch1.png)

To build this Integration Procedure:

1. From the Vlocity Integration Procedures tab, click **New**.
2. Provide an **Integration Procedure Name**, a **Type**, and a **SubType**, and click **Save**.
3. Drag a Try-Catch Block into the Structure panel and give it the following settings:
    
    1. Under Failure Response, click **Add Key/Value Pair**. Set the Key to `failureResponse` and the Value to `You must provide a last name.`
    2. Make sure the **Fail on Block Error** checkbox is checked.
4. Create the Data Mapper Load that the Data Mapper Post Action component calls:
    
    1. Give it a **Data Mapper Interface Name** of `CreateContact` and an **Interface Type** of **Load**.
    2. On the Objects tab, click **Add Object** and select **Contact**.
    3. On the Fields tab, click the **+** icon and enter `LastName` as both the **Input JSON Path** and the **Domain Object Field**.
    
    If you aren't sure how to create a Data Mapper Load, see the examples 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.").
5. Drag a Data Mapper Post Action component into the Try-Catch Block and give it the following settings:
    
    1. Set the **Element Name** to `DRPostAction1`.
    2. Set the **Data Mapper Interface** to `CreateContact`.
    3. Make sure the **Fail on Step Error** checkbox is checked.
6. Drag a Delete Action component after the Try-Catch Block. Under Delete SObject, set the **Type** to **Contact** and the **Path To Id** to `%DRPostAction1:Contact_1:Id%`.
7. Drag a Response Action into the Structure panel as the last component and check the **Return Full Data JSON** checkbox.
8. Go to the Preview tab and test the Integration Procedure:
    
    1. Under Input Parameters, click **Add New Key/Value Pair**.
    2. Set the Key to `LastName` and the Value to any name you like.
    3. Click **Execute**.
    
    The output should look something like this:
    
    ```
    {
      "response": {},
      "ResponseAction1Status": true,
      "DeleteAction1": [
        {
          "errors": [],
          "success": true,
          "id": "0034N00001rNgqqQAC"
        }
      ],
      "DeleteAction1Status": true,
      "TryCatchBlock1": null,
      "TryCatchBlock1Status": true,
      "DRPostAction1": {
        "ActualTime": 626,
        "CpuTime": 345,
        "Contact_1": [
          {
            "UpsertSuccess": true,
            "Id": "0034N00001rNgqqQAC",
            "LastName": "Aristotle"
          }
        ],
        "error": "OK",
        "responseType": "SObject"
      },
      "DRPostAction1Status": true,
      "options": {
        "queueableChainable": false,
        "ignoreCache": true,
        "resetCache": false,
        "chainable": false
      },
      "LastName": "Aristotle"
    }
    ```
9. Make the Value blank and click **Execute** again. The output should look something like this:
    
    ```
    {
      "result": {
        "failureResponse": "You must provide a last name."
      },
      "success": false
    }
    ```