Skip to main content

Example 2 - Cascading lookup list

Introduction

This example demonstrates the following scenario:

I want to filter a lookup list based on the value chosen in another lookup list.

Let's imagine an example of this:

My item form has controls for two Link attributes named Team and Team Member.

If a value is chosen in the Team control, the Team Member control should only list members of that team. I can create an expression that:

  • uses an AQS query to fetch items of Team Members with a parent whose Item ID matches a parameter

  • reads the Value property of the Team control (the Item ID of the chosen team)

  • injects that value into the AQS query to populate the parameter

1 Create the expression

When editing an item form, select Expressions in the app bar. On the left, select Add to create an expression.

The Expressions box

In the Item Form Expression Builder, select Edit at the top. Enter a descriptive name and select Save.

The edited name of the new expression

2 Add a literal AQS

Select Literals in the app bar and choose AQS to add a node to the canvas.

Select the node's Edit button. Select Value to open the AQS Builder. Build your query and then select Save.

Build the AQS query

This query fetches items of the Team Members design, with a parent whose Item ID matches a parameter.

  1. In the AQS Builder, select Add in the left Parameters box. Configure as shown below and select Save.
Properties of your new parameter in the AQS Builder
  1. Select the root node and set its Design or interface to Team Members.
The selected root node in the AQS Builder
  1. Select Add and choose the Equals node.
Adding an Equals node in the AQS Builder
  1. Select the left segment, select the Property node and then Item id.
Populating the left segment of the Equals node in the AQS Builder
  1. Select to open the Pathfinder. On the left, select Navigate > Teams > Via Members > Select this. Select Done to finish.
Selecting the parent Team in the Pathfinder
  1. Select the right segment, select Item, select Parameter and then choose your parameter.
Populating the right segment of the Equals node in the AQS Builder
  1. Select Done to finish and close the AQS Builder.
The literal node appears on the canvas

3 Add a literal String

Select Literals in the app bar and choose String to add a node to the canvas.

Select the node's Edit button. Enter the exact name of your AQS parameter and select Save.

The literal node appears on the canvas

4 Add a global Alloy ID Array

Select Global in the app bar and choose Alloy ID Array to add a node to the canvas.

Select the node's Edit button. Select Global value, choose Team Value and then select Save.

The global node appears on the canvas
A list of available values for the global node

5 Add an AQS Set Parameter

Select Transforms in the app bar and choose AQS Set Parameter to add a node to the canvas.

The transform node appears on the canvas

6 Add a final AQS

Select Finals in the app bar and choose AQS to add a node to the canvas.

The final node appears on the canvas

For the first three nodes, select their right circle and then select the relevant left circle on the AQS Set Parameter node. Repeat to link the AQS Set Parameter node to the final AQS node.

Select Save to finish.

All the nodes linked together

8 Target the expression

Back in the Item Form Builder, select the Team Member control. For its Query property, select Target and choose your saved expression.

Select Save to finish.

The Query property of the Team Member control showing as targeted to the expression