Skip to navigation

Use FQL conditional logic to select data

View as Markdown

You can use Flows Query Language (FQL) to filter for specific data in your responses. Multiple responses return in an array. Single responses return as a single record. Sample data and FQL examples are below.

Example JSON

The examples below use this JSON object in a variable named data:

{
"customer_info": {
"customer field": "Customer data",
"unformatted_customer_field": " customer \n stuff ",
"total_value": "281.01",
"associated_usernames": ["user1", "myuser", "online_user"]
},
"payments": [
{
"invoice_number": "101301",
"date": "2022-09-11T16:12:34.494Z",
"description": "recurring subscription",
"amount": 110.48
},
{
"invoice_number": "101302",
"date": "2022-09-29T14:45:13.148Z",
"description": "one time purchase",
"amount": 24.49
},
{
"invoice_number": "101303",
"date": "2022-10-11T16:12:34.683Z",
"description": "recurring subscription",
"amount": 110.48
},
{
"invoice_number": "101304",
"date": "2022-10-12T11:45:22.182Z",
"description": "recurring subscription deluxe",
"amount": 35.56
}
]
}

Filter query results for objects with specific key-value pairs

The example below filters for objects in the payments array that have the key-value pair "description": "recurring subscription".

FQLdata.payments[description="recurring subscription"]
Result
[
{
"invoice_number": "101301",
"date": "2022-09-11T16:12:34.494Z",
"description": "recurring subscription",
"amount": 110.48
},
{
"invoice_number": "101303",
"date": "2022-10-11T16:12:34.683Z",
"description": "recurring subscription",
"amount": 110.48
}
]

FQL uses the same syntax to navigate filtered query results as it does to navigate JSON data. The example below gets the values from the invoice_number fields in the filtered results.

FQLdata.payments[description="recurring subscription"].invoice_number
Result

["101301","101303"]

Return a single record

When a filter has a single result, FQL returns that result as a single value instead of an array. The filter below matches one payment, so it returns the invoice number as a string.

FQLdata.payments[description="recurring subscription deluxe"].invoice_number
Result"101304"

Check if a field contains specific text

The $contains function checks whether a string contains specific text and returns true or false. The example below checks whether the description value of the first item in the payments array contains the text recurring.

FQL$contains(data.payments[0].description, "recurring")
Resulttrue

Get only unique payment amounts

The $distinct function returns a single instance of any recurring values. In the example below, the 110.48 value appears twice in the data, but only once in the result.

FQL$distinct(data.payments.amount)
Result[110.48, 24.49, 35.56]