---
schema_version: "1"
id: 48f3f796eb6db013fea1b145b069b1ddd352e0f5402784e9a7125254dba208b7
title: Navigating Data in a Data Graph
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/marketing-cloud/handlebars/guide/mcn-handlebars-guide-data-graph-navigating.md
canonical_url: https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/guide/mcn-handlebars-guide-data-graph-navigating.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 1ebf1ace2c64dcb901c4efe0587c48d6207193af46c9c5c41b2c92adae302aa2
products:
  - Handlebars for Marketing Cloud Next
  - Marketing Cloud
---
# Navigating Data in a Data Graph

Before you read this section, review the concepts in [Understanding Data Graphs in Marketing Cloud Next](https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/guide/mcn-handlebars-guide-data-graph-understanding.md).

## Using the Get Helper

With Handlebars, it’s common to use dot notation to access nested fields in a JSON object. In Marketing Cloud Engagement, you can use the `get` helper function as an alternative to dot notation. By using the `get` function, you can [filter](#filtering-data) and [sort](#sorting-data) objects, which isn't possible with dot notation.

The `get` function uses a simple syntax:

```
{{get collection indexOrKey}}
```

For the `collection` parameter, specify the object or array that contains the data you want to retrieve. For the `indexOrKey` parameter, specify the numerical index (zero-indexed) for arrays or the name of the target field or object.

For example, assume that the data in your data graph resembles this JSON object.

```json
{
  "ssot__Id__c": "7471ce0c3b44998ffb8342eabdf2c02b",
  "ssot__FirstName__c": "Erica",
  "ssot__LastName__c": "Douglass",
  "ssot__PersonName__c": "Erica Douglass",
  "ssot__ResidenceCountryName__c": "",
  "ssot__TitleName__c": "",
  "IndividualIdentityLink__dlm": [
    {
      "SourceRecordId__c": "003Ws00000QxpYzIAJ",
      "UnifiedRecordId__c": "7471ce0c3b44998ffb8342eabdf2c02b",
      "ssot__DataSourceId__c": "Salesforce_Home",
      "ssot__DataSourceObjectId__c": "Contact",
      "ssot__Individual__dlm": [
        {
          "ssot__FirstName__c": "Erica",
          "ssot__Id__c": "003Ws00000QxpYzIAJ",
          "ssot__LastName__c": "Douglass",
          "ssot__PersonName__c": "Erica Douglass",
          "ssot__TitleName__c": "",
          "BookStoreProfile__dlm": [
            {
              "FavoriteGenre__c": "Fantasy",
              "LastVisitedStoreId__c": "2121",
              "LoyaltyTier__c": "Bronze",
              "MemberId__c": "003Ws00000QxpYzIAJ",
              "RewardPoints__c": 80,
              "BookStore__dlm": [
                {
                  "StoreAddress__c": "331 Town Square Drive, Decatur GA, 30012",
                  "StoreHoursDays__c": "Mon - Sun",
                  "StoreHoursTime__c": "8am - 8pm",
                  "StoreId__c": "2121",
                  "StoreName__c": "RL at Town Square",
                  "BookStoreEvent__dlm": [
                    {
                      "EventDate__c": "2026-07-22T20:00:00.000Z",
                      "EventDescription__c": "Guest visit from an author",
                      "EventName__c": "Monthly Author Visit",
                      "StoreEventId__c": "6",
                      "StoreId__c": "2121"
                    },
                    {
                      "EventDate__c": "2026-07-20T19:00:00.000Z",
                      "EventDescription__c": "Lively storytelling for the little ones!",
                      "EventName__c": "Weekly Storytime",
                      "StoreEventId__c": "5",
                      "StoreId__c": "2121"
                    },
                    {
                      "EventDate__c": "2026-07-15T20:00:00.000Z",
                      "EventDescription__c": "Monthly book club for young adults",
                      "EventName__c": "Young Adult Book Club",
                      "StoreEventId__c": "4",
                      "StoreId__c": "2121"
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
```

When you write Handlebars code that uses the `get` helper function, it’s helpful to start from the inside and work outward. When you use data from the data graph, the first step is to return the root data graph (`get @root "$dataGraph"`). Use the returned data as the first argument in the outer `get` function, and then specify the field to return from that data (in this case, `ssot__FirstName__c`) as the second argument. For example, to return the individual's first name, which is found in the `ssot__FirstName__c` field in the first level of the object, use this code.

```
{{get (get @root "$dataGraph") "ssot__FirstName__c"}}
```

## Changing Context

Handlebars includes the `#with` helper, which defines a context area. This helper is useful when you want to access multiple objects or properties that are nested several levels deep in a data object.

For example, if you know that you want to refer to several fields in the `ssot__Individual__dlm` array from the preceding section, you can create an alias to the object. This example shows how to associate the first object in the `ssot__Individual__dlm` array to the alias `Individual` and then use properties from that object in the HTML body of a message.

```
<body>
  {{#with @root.$dataGraph.IndividualIdentityLink__dlm.[0].ssot__Individual__dlm.[0] as |
Individual |}}
    <p>Hello {{Individual.FirstName}}!</p>
    <p>Your favorite genre is {{Individual.BookStoreProfile__dlm.[0].FavoriteGenre__c}}.</p>
  {{/with}}
</body>
```

Using aliases makes your template code easier to understand and can prevent errors that result from traversing complex objects.

## Filtering Data

The `filter` helper function has this syntax:

```
{{filter list fieldName comparisonOperator targetValue filterAs}}
```

For the `list` parameter, specify the object that contains the data to filter. For the `fieldName` parameter, specify the field to filter on. For the next two parameters, specify the filter criteria. Finally, for the `filterAs` parameter, specify the data type to use in the filter.

This example uses the sample JSON object from the preceding section. The code uses nested `get` functions. The innermost `get` function returns the root data graph object. The `get` function outside of that returns the content of the `IndividualIdentityLink__dlm` object in the data graph. From that object, the `filter` function returns all data in which the value of the `ssot__DataSourceObjectId__c` is a string that equals "Contact".

```
{{filter (get (get @root "$dataGraph") IndividualIdentityLink__dlm) "ssot__DataSourceObjectId__c" "EQUALS" "Contact" "string"}}
```

The function returns an object that matches the filter criteria.

```json
{
  "SourceRecordId__c": "003Ws00000QxpYzIAJ",
  "UnifiedRecordId__c": "7471ce0c3b44998ffb8342eabdf2c02b",
  "ssot__DataSourceId__c": "Salesforce_Home",
  "ssot__DataSourceObjectId__c": "Contact",
  "ssot__Individual__dlm": [
    {
      "ssot__FirstName__c": "Erica",
      "ssot__Id__c": "003Ws00000QxpYzIAJ",
      "ssot__LastName__c": "Douglass",
      "ssot__PersonName__c": "Erica Douglass",
      "ssot__TitleName__c": "",
      "BookStoreProfile__dlm": [
        {
          "FavoriteGenre__c": "Fantasy",
          "LastVisitedStoreId__c": "2121",
          "LoyaltyTier__c": "Bronze",
          "MemberId__c": "003Ws00000QxpYzIAJ",
          "RewardPoints__c": 80,
          "BookStore__dlm": [
            {
              "StoreAddress__c": "331 Town Square Drive, Decatur GA, 30012",
              "StoreHoursDays__c": "Mon - Sun",
              "StoreHoursTime__c": "8am - 8pm",
              "StoreId__c": "2121",
              "StoreName__c": "RL at Town Square",
              "BookStoreEvent__dlm": [
                {
                  "EventDate__c": "2026-07-22T20:00:00.000Z",
                  "EventDescription__c": "Guest visit from an author",
                  "EventName__c": "Monthly Author Visit",
                  "StoreEventId__c": "6",
                  "StoreId__c": "2121"
                },
                {
                  "EventDate__c": "2026-07-20T19:00:00.000Z",
                  "EventDescription__c": "Lively storytelling for the little ones!",
                  "EventName__c": "Weekly Storytime",
                  "StoreEventId__c": "5",
                  "StoreId__c": "2121"
                },
                {
                  "EventDate__c": "2026-07-15T20:00:00.000Z",
                  "EventDescription__c": "Monthly book club for young adults",
                  "EventName__c": "Young Adult Book Club",
                  "StoreEventId__c": "4",
                  "StoreId__c": "2121"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}
```

## Sorting Data

The `sort` helper function has this syntax:

```
{{sort list fieldName sortOrder sortAs}}
```

For the `list` parameter, specify the object that contains the data to filter. For the `fieldName` parameter, specify the field to sort on. For `sortOrder`, specify whether to sort in ascending (`asc`) or descending (`desc`) order. Finally, for `sortAs`, specify the data type to use in the sort operation.

This example uses the same sample JSON object from the preceding section and builds on the `filter` example.

**note:** This code example uses line breaks and indentation to improve readability. This example is valid, but with Handlebars it’s more common for a section of code such as this to be combined onto one line.

```
{{sort
  (get
    (get
      (get
        (filter
          (get
            (get @root "$dataGraph")
          IndividualIdentityLink__dlm)
        "ssot__DataSourceObjectId__c"
        "EQUALS" "Contact" "string")
      BookStoreProfile__dlm)
    BookStore__dlm)
  BookStoreEvent__dlm)
"EventDate__c" "asc" "date"}}
```

Working from the inside out, this code example completes these steps:

1. Returns the root data graph (`get @root "$dataGraph"`).
2. From the root data graph, returns the content of the `IndividualIdentityLink__dlm` object.
3. From the `IndividualIdentityLink__dlm` object, returns the object for which the value of the `ssot__DataSourceObjectId__c` property is a string that equals "Contact".
4. From the filtered object, returns the contents of the `BookStoreProfile__dlm` object.
5. From the `BookStoreProfile__dlm` object, returns the contents of the `BookStore__dlm` object.
6. From the `BookStore__dlm` object, returns the contents of the `BookStoreEvent__dlm` object sorted in ascending date order by the `EventDate__c` property.

The code returns the list of objects from the `BookStoreEvent__dlm` array, sorted by date from earliest to latest.

```json
[
  {
    "EventDate__c": "2026-07-15T20:00:00.000Z",
    "EventDescription__c": "Monthly book club for young adults",
    "EventName__c": "Young Adult Book Club",
    "StoreEventId__c": "4",
    "StoreId__c": "2121"
  },
  {
    "EventDate__c": "2026-07-20T19:00:00.000Z",
    "EventDescription__c": "Lively storytelling for the little ones!",
    "EventName__c": "Weekly Storytime",
    "StoreEventId__c": "5",
    "StoreId__c": "2121"
  },
  {
    "EventDate__c": "2026-07-22T20:00:00.000Z",
    "EventDescription__c": "Guest visit from an author",
    "EventName__c": "Monthly Author Visit",
    "StoreEventId__c": "6",
    "StoreId__c": "2121"
  }
]
```
