Skip to main content

Example 4 - Parameters and AQS Join

This example demonstrates how to build the following query in the AQS Builder:

Fetch all inspections assigned to a particular team

In full detail:

Fetch items of the Inspections interface with a Link attribute that references a Teams item, which has a Team Name attribute equal to some text

We'll use a TeamName parameter as a placeholder for "some text".

Configure the root node

  1. Select the root node and set the following properties:

    • AQS Type - AQS Join
    • Design or interface - Inspections
    • Collection - Live
    • Attributes - Title, Subtitle, Team Name

Note that we're using AQS Join for this query because we're not only fetching attribute data from the queried Inspections items, but also the Teams items they link to (to get the value of their Team Name attribute).

alt text

When selecting attributes in the Pathfinder, follow the Team Link attribute to the Teams design, where you can then select its Team Name attribute.

alt text

Add a parameter

  1. Select and populate the fields like so:
alt text
alt text
Note

To change how the parameter looks in Alloy, supply a Display Name. It'll still be called Name in the underlying AQS code.

Add a comparison node

  1. Select and choose the Equals node type from the list.
alt text
alt text

Fill the left segment

  1. Select on the left and choose the Attribute node type from the list. The node will default to the first relevant attribute in the design/interface being queried.
alt text
alt text
  1. Select and use the Pathfinder to navigate to the Teams design and select its Team Name attribute (see step 1).
alt text
Note

The indicates that the selected attribute belongs to another design/interface than the one being queried.

Fill the right segment

  1. Select on the right and choose the Text node type. Select Parameter and choose TeamName.
alt text
alt text
alt text

Finish

  1. Select Done (bottom-left) to finish.
See JSON code
{
"type": "Join",
"properties": {
"attributes": ["attributes_itemsTitle", "attributes_itemsSubtitle"],
"collectionCode": "Live",
"dodiCode": "designInterfaces_inspections",
"joinAttributes": ["root.attributes_tasksTeam.attributes_teamsTeamName"],
"parameters": [
{
"name": "TeamName",
"type": "String"
}
]
},
"children": [
{
"type": "Equals",
"children": [
{
"type": "Attribute",
"properties": {
"attributeCode": "attributes_teamsTeamName",
"path": "root.attributes_tasksTeam"
}
},
{
"type": "String",
"properties": {
"parameterName": "TeamName"
}
}
]
}
]
}

Populating the parameter

When a user runs the query, they'll be prompted to supply a value for the parameter.

alt text
alt text
Note

As shown above, it's possible to add multiple values for the parameter. The query will fetch any Jobs item linked to a Teams with an applicable Team Name value.