FQL allows us to apply operators to any of the fields listed in the field reference guide to return objects where the field matches the criteria we specify.
Creating an FQL Query
An FQL Query must contain at least two clauses.
Field - you must select a field that you wish to base your query on.
Value - you must specify a value that you wish that field to match.
To create a query that returns all Tickets that are in the resolved status.
Find the field that holds Ticket status infomation in the field reference guide
ticket.status
You then need to find an operator that selects all Tickets where this field shows the Ticket is resolved. Again if you look on the field reference guide next to the tickets.status field we'll see the operator listed as String comparison.
Go to the operators guide and check the operators available for a string comparison. You'll see the options available are
=, !=, in, not in
.You'll then need to match the string 'resolved' to the contents of
ticket.status
. Per the operators list we can use eitherIN
OR=
Using IN
ticket.status IN ('resolved') copy
Using =
ticket.status = 'resolved' copy
In this instance either of these operators work. However, using IN
affords you additional flexibility, as if you decided you wanted to include additional statuses in the query (e.g., archived) it would be very easy to adjust it:
ticket.status IN ('resolved', 'archived') copy
Adding Multiple Arguments to a Query
It is possible to add multiple arguments to a search using the logical operator AND.
We can use AND to make a search more specific as it allows us to apply the criteria from multiple fields to our query.
To create a query for all resolved Tickets that have been resolved from one department.
Take the query from the previous example to return resolved Tickets
ticket.status IN ('resolved')
.Go to the field reference guide and find the field that holds the details of the Ticket department
ticket.department
Again check the operator for this field in the field reference guide (in this instance it is 'ID ref') and check the operators guide to see the options available (we will use
ticket.department =
in this instance).Go to Admin > Ticket Structure > Departments and grab the ID number for your Ticket department.
Add this to your Ticket department query so we have
ticket.department = 1
and the originalticket.status IN ('resolved')
. We can then simply combine these with AND so our query returns just resolved Tickets from department ID 1.
ticket.status = 'resolved' AND ticket.department = 1 copy
Please log in or register to submit a comment.