# Curate a List of Items

Many controllers read a list of items and then manage their playout.

Examples include lists that are constantly updating such as chat messages or lists that are prepared such as a class list for a graduation.

A common need is to be able to parse a list, display it, and allow the user to pick items in the list and play them in.

This example reads random images from various artists and builds a list of them.

<figure><img src="/files/z93cnxw0FtfD76J6U0yA" alt=""><figcaption></figcaption></figure>

Take a look at the source code to see how it works.

Of particular interest:

#### Pre-Render <a href="#pre-render" id="pre-render"></a>

As each image is downloaded, a `scheduleAction` call is made to prepare that item so it will be ready to play whenever the user clicks the play button.

```javascript
scheduler.scheduleAction('render', inputName, '', {
  Name: jsonReply.author,
  Subtitle: jsonReply.url,
  Image: requestPicture.responseURL,
});
```

These renders will be cached in the project, so that they can be played in any order whenever they are needed.

#### Automatic Action <a href="#automatic-action" id="automatic-action"></a>

Each list item includes a “Play” button. Pressing this sends the “automatic” action to the `scheduler`. “automatic” is a natural choice for lists.

* If the title is not playing, “automatic” becomes “animateIn” and animates the Title in with the selected list item’s values.
* If the title is live with another list item, “automatic” becomes “update” and animates only the changes.
* If the title is live with the current list item, “automatic” becomes “animateOut” and animates the Title out.

```javascript
// When the user clicks play, use the automatic action
// which will animate in, animate out, or update,
// depending on Title play status and Variable values.
scheduler.scheduleAction('automatic', inputName, '', {
  Name: jsonReply.author,
  Subtitle: jsonReply.url,
  Image: requestPicture.responseURL,
});
```

This saves you from writing special state logic to track the status of the Titles and determine what action to take when the Play button is clicked.

#### Dynamic Input Definition <a href="#dynamic-input-definition" id="dynamic-input-definition"></a>

Although prior examples showed setting up variables in the XML configuration, they can also be set manually through the API using the `updateInputDefinition` command.

```javascript
// Redefine this input as having the three variables that we wish to use for this list.
scheduler.updateInputDefinition(ServiceHandler.inputName, {
  variables: {
    Name: { type: 'text', tags: 'name' },
    Subtitle: { type: 'text' },
    Image: { type: 'image' },
  },
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developers.newbluefx.com/api-examples/sample-controllers-tour/07-curate-a-list-of-items.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
