Loading
Salesforce now sends email only from verified domains. Read More
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Create a Try-Catch Block Example

          Create a Try-Catch Block Example

          An Integration Procedure creates and deletes a Contact with the specified LastName and returns an error message if the LastName is blank.

          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.

          To build this Integration Procedure:

          1. From the Omnistudio 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.

          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
            }
            
           
          Loading
          Salesforce Help | Article