Skip to main content

Example 2 - Cascading lookup list

This example demonstrates the following scenario:

I want to filter items in a lookup list based on the selected value of a previous lookup list

Let's imagine an example of this:

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

After a user selects a value in the Teams control, I want the Team Members control to only list members of the selected team. So I'll create an expression that:

  • contains an AQS query that only fetches Team Members items with a parent whose Item ID matches a parameter

  • reads the Value property of the Teams control

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

Create and name the expression

  1. While editing an item form, select in the Expressions box to create a new expression.
The Expressions box
  1. In the Item Form Expression Builder, select at the top to name the expression with a clear description of what it does.
The edited name of the new expression

Add a literal AQS node

  1. Select Literal in the top toolbar and choose AQS to add a node to the canvas.
The literal node appears on the canvas
  1. Select on the node to open the AQS Builder. Build your query and then select Save.
Building the AQS query

This query will only fetch Team Members items with a parent whose Item ID matches a parameter.

Create a parameter

  1. In the AQS Builder, select in the left Parameters box. Configure as illustrated below and then select Save.
Properties of your new parameter in the AQS Builder

Add an Equals condition

  1. Select the root node and set its Design or interface to Team Members.
The selected root node in the AQS Builder
  1. Select and choose the Equals node.
Adding an Equals node in the AQS Builder

Fill the left segment

  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 the Pathfinder.

On the left, select Navigate > Teams > Via Members > Select this > Done.

Selecting the parent Team in the Pathfinder

Fill the right segment

  1. Select the right segment, select Item, select Parameter and then choose your parameter.
Populating the left segment of the Equals node in the AQS Builder

Finish

  1. Select Done to return to the Item Form Expressions Builder.

Add a literal String node

  1. Select Literal in the top toolbar and choose String to add a node to the canvas.
The literal node appears on the canvas
  1. Select on the node, enter the exact name of your AQS parameter, and then select Save.

Add a global Alloy ID Array node

  1. Select Global in the top toolbar and choose Alloy ID Array to add a node to the canvas.
The global node appears on the canvas
  1. Select on the node, select Global value and then choose Team Value.
A list of available values for the global node

Add an AQS Set Parameter node

  1. Select Transforms in the top toolbar and choose AQS Set Parameter to add a node to the canvas.
The transform node appears on the canvas

Add a final AQS node

  1. Select Final in the top toolbar and choose AQS to add a node to the canvas.
The final node appears on the canvas
  1. 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 to the final AQS node.
All the nodes linked together

Save and target

  1. Select Save (bottom-left) to finish.

  2. Back in the Item Form Builder, select the Team Members control, select beside its Query property and choose your new expression.

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

Don't forget to save your item form!