Loading
 Experience Cloud – Feature Degradation on Lightning Web Runtime SitesRead More
The Trailblazer Community is now read-only Read More
Convert a List of Objects to a List of Values (Managed Package)

Convert a List of Objects to a List of Values (Managed Package)

For the managed package runtime, you can convert a list of JSON objects (key-value pairs in braces) to a list of single values, regardless of the length of the list. The trick is to use a formula to remove the second level of the hierarchy.

Managed Package app icon This information is for Omnistudio for Managed Packages. For Omnistudio on standard runtime, see Omnistudio Help.

To download a data pack of this example for Omnistudio for Managed Packages, click here.

To create an Omnistudio Data Mapper Transform that converts a list of objects to a list of values:

  1. Go the Data Mapper Designer tab and click New. The Create dialog is displayed.
  2. Specify a name for the Data Mapper and configure its settings as follows:
    • Interface Type — Transform

    • Input Type — JSON

    • Output Type — JSON

  3. Click Save. The Transforms tab of the Data Mapper Interface page is displayed.
  4. Go to the Formulas tab. In the Formula field, enter ObjectList:Property. In the Formula Result Path field, enter FormulaList.
  5. Go to the Transforms tab. Expand the Input JSON pane and paste the following JSON data into it:
    {
      "ObjectList": [
        {
          "Property": "P9034"
        }
      ]
    }
    
  6. Expand the Expected JSON Output pane and paste the following JSON data into it:
    {
      "PropertyValueList": [
        "P9034"
      ]
    }
    
  7. Click the + icon and add the following mapping:
    • Input JSON Path — FormulaList

    • Output JSON Path — PropertyValueList

    Note that you only have to create a mapping between the top-level nodes.

  8. Expand the Current JSON Output pane. Its contents should look like this:
    {
      "PropertyValueList": "Text"
    }
    
  9. Go to the Preview tab and paste the following JSON data into the Input pane:
    {
      "ObjectList": [
        {
          "Property": "P9034"
        },
        {
          "Property": "P6538"
        },
        {
          "Property": "P1234"
        },
        {
          "Property": "P5678"
        },
        {
          "Property": "P2345"
        },
        {
          "Property": "P7654"
        }
      ]
    }
    
    
  10. Click Execute. The Response should look like this:
    {
      "PropertyValueList": [
        "P9034",
        "P6538",
        "P1234",
        "P5678",
        "P2345",
        "P7654"
      ]
    }
    
  11. Add or subtract list items in the JSON data in the Input pane and click Execute again. Note that the output changes accordingly.
 
Loading
Salesforce Help | Article