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
- While editing an item form, select in the Expressions box to create a new expression.
- In the Item Form Expression Builder, select at the top to name the expression with a clear description of what it does.
Add a literal AQS node
- Select Literal in the top toolbar and choose AQS to add a node to the canvas.
- 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
- In the AQS Builder, select in the left Parameters box. Configure as illustrated below and then select Save.
Add an Equals condition
- Select the root node and set its Design or interface to Team Members.
- Select and choose the Equals node.
Fill the left segment
- Select the left segment, select the Property node and then Item id.
- Select to open the the Pathfinder.
On the left, select Navigate > Teams > Via Members > Select this > Done.
Fill the right segment
- Select the right segment, select Item, select Parameter and then choose your parameter.
Finish
- Select Done to return to the Item Form Expressions Builder.
Add a literal String node
- Select Literal in the top toolbar and choose String to add a node to the canvas.
- Select on the node, enter the exact name of your AQS parameter, and then select Save.
Add a global Alloy ID Array node
- Select Global in the top toolbar and choose Alloy ID Array to add a node to the canvas.
- Select on the node, select Global value and then choose Team Value.
Add an AQS Set Parameter node
- Select Transforms in the top toolbar and choose AQS Set Parameter to add a node to the canvas.
Add a final AQS node
- Select Final in the top toolbar and choose AQS to add a node to the canvas.
Link them together!
- 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.
Save and target
-
Select Save (bottom-left) to finish.
-
Back in the Item Form Builder, select the Team Members control, select beside its Query property and choose your new expression.
Don't forget to save your item form!