Skip to main content

Example 4 - Parameters and AQS Join

Reuse a parameter across linked data

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

Fetch all inspections assigned to a particular team.

In AQS terms:

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".

1 Configure the root node

Select the root node and set:

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

This query uses AQS Join because it returns data from the Teams items that the inspections link to, not just from the inspections themselves.

The root node configured as an AQS Join

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

Following a Link attribute to select Team Name

2 Add the parameter

Select Add parameter and fill in the parameter's fields.

Opening the parameter window
The fields of the Parameter window
info

Enter a Display Name to change how the parameter is labelled. The underlying AQS code will still use Name.

3 Add the comparison

Select Add node and choose Equals.

Choosing the Equals node from the list
An empty Equals node on the query branch

4 Read the linked Team Name

Select the left segment and choose Attribute.

Choosing the Attribute node type
The Attribute node filling the left segment

Select and use the Pathfinder to reach the Teams design and select Team Name, as in step 1.

Selecting Team Name on the linked Teams design
info

The shows that the attribute belongs to a connected design/interface rather than the one being queried.

5 Use the parameter

Select the right segment and choose Text. Select Parameter and choose TeamName.

Selecting the TeamName parameter

6 Finish

Select Done (bottom-left) to finish.

The finished query
See JSON code

This code may reference designs, interfaces, attributes or items that don't exist in your company project.

{
"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"
}
}
]
}
]
}

Running the query

Whenever someone runs the query, they will be prompted to provide a value for the parameter.

Being prompted to supply the TeamName parameter
Supplying multiple values for the parameter
info

You can supply more than one value. The query will fetch inspections linked to a team matching any of them.