
# How do I access a chooser field's chosen asset?

> Check that an asset is actually chosen before reading its properties, using the API's asset property or an XPath test on the path element.

URL: https://www.hannonhill.com/cascadecms/latest/articles/developing-in-cascade/script-formats/access-chosen-asset.html
category: Developing in Cascade
article-type: how-to
content-kind: faq
release-availability: all
tags: data-definitions, velocity
updated: 2026-10-06

## With the Cascade API

Choosers expose an `asset` property, set to the chosen asset's API object if one is chosen, or `null` if not. Because it can be `null`, check before accessing its properties:

```velocity
#set ($thumbnailImage = $currentPage.getStructuredDataNode("thumbnail-image"))
#if (!$_PropertyTool.isNull($thumbnailImage.asset))
    <img src="${thumbnailImage.asset.link}"/>
#end
```

## With an Index Block and the XPath Tool

In an Index Block, a chooser field contains XML elements describing the asset — name, path, link, site, and so on. If no asset is chosen, you get a `path` of `/` and no other elements. Check first here too:

```velocity
#set ($thumbnailImage = $_XPathTool.selectSingleNode($contentRoot, "/system-index-block/calling-page/system-page/system-data-structure/thumbnail-image[path != '/']"))
#if ($thumbnailImage.size() > 0)
    <img src="${thumbnailImage.getChild("link").value}" />
#end
```

## Not seeing the chosen asset's contents?

By default, the structured data content for a chosen asset isn't present in an Index Block rendering, or in the generated `system-data-structure` in the DEFAULT region when no Index Block is assigned. You'll see an empty `<content></content>` element instead.

To include it, edit the Data Definition containing the chooser field, open the chooser field's settings, and set **Render Content Depth** to at least `2`. Depending on the structure of the chosen asset, a higher value may be needed.
