Loading
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 with a Formula

          Create a Try-Catch Block Example with a Formula

          An Integration Procedure finds Contacts with the specified Name and returns an error message if none are found. Because returning no records normally isn't considered a failure, the Omnistudio Data Mapper Extract Action within the Try-Catch Block includes a Failure Condition Formula.

          The Integration Procedure has these components:

          • A Try-Catch Block, named TryCatchBlock1

          • A Data Mapper Extract Action, named DRExtractAction1

          • 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. Create the Data Mapper Extract that the Integration Procedure calls:
            1. From the Omnistudio Data Mapper tab, click New.

            2. Enter a Data Mapper Interface Name of GetContactName and an Interface Type of Extract, and click Save.

            3. On the Extract tab, click Add Extract Step and select Contact. Specify the path and filter Contact Name LIKE Name.

            4. On the Output tab, click the + icon and enter Contact:Name as the Extract JSON Path and ContactName as the Output JSON Path.

            If you aren't sure how to create a Data Mapper Extract, see the examples in Omnistudio Data Mapper Extract Examples.

          2. From the Omnistudio Integration Procedures tab, click New.
          3. Provide an Integration Procedure Name, a Type, and a SubType, and click Save.
          4. 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 Name %Name% not found.

            2. Make sure the Fail on Block Error checkbox is checked.

          5. Drag a Data Mapper Extract Action component within the Try-Catch Block and give it the following settings:
            1. Set the Element Name to DRExtractAction1.
            2. Set the Data Mapper Interface to GetContactName.

            3. Make sure the Fail on Step Error checkbox is checked.

            4. Specify this Failure Condition Formula:

              ISBLANK(ContactName)
          6. Drag a Response Action after the Try-Catch Block and check the Return Full Data JSON box.
          7. 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 Name and the Value to any first or last name you like.

            3. Click Execute.

            If at least one Contact with that Name is found, the output looks something like this:

            {
              "Name": "Leanne",
              "TryCatchBlock1": null,
              "DRExtractAction1Status": true,
              "TryCatchBlock1Status": true,
              "ResponseAction1Status": true,
              "options": {
                "vlcFilesMap": null,
                "forceQueueable": false,
                "mockHttpResponse": null,
                "vlcApexResponse": true,
                "ParentInteractionToken": null,
                "useFuture": false,
                "isTestProcedure": false,
                "useQueueable": false,
                "disableMetadataCache": false,
                "resetCache": false,
                "vlcIPData": null,
                "OmniAnalyticsTrackingDebug": false,
                "ignoreCache": true,
                "isDebug": true,
                "queueableChainable": false,
                "useContinuation": false,
                "chainable": false,
                "shouldCommit": false,
                "vlcTestSuiteUniqueKey": null,
                "vlcTestUniqueKey": null,
                "vlcCacheKey": null,
                "useHttpCalloutMock": false,
                "continuationStepResult": null,
                "useQueueableApexRemoting": false
              },
              "DRExtractAction1": {
                "ContactName": "Leanne Tomlin"
              },
              "response": {}
            }
          8. Change the Value to an uncommon name (or make it blank) and click Execute again. The output looks something like this:
            {
              "success": false,
              "result": {
                "error": [],
                "failureResponse": "Name Quincy not found.",
                "success": false,
                "result": []
              }
            }
           
          Loading
          Salesforce Help | Article