Page tree
Skip to end of metadata
Go to start of metadata

You can embed JQL and S-JQL in a formula to check if the item (the one the formula is being calculated for) satisfies the condition of the query – that is, it will be a part of the query result.

The syntax is similar to calling an aggregate function:

  • IF JQL { assignee in membersOf("Team-Alpha") } : ...
  • IF NOT SJQL { descendant of folder("Excluded") } : ...

The result of evaluating JQL {} or SJQL {} is always 0 (false) or 1 (true).

When SJQL is used, it is always applied to the current structure. (Or the one being generated – see the note below.)

Note that, unlike aggregate functions, these constructs do not use Expr, but rather another other languages, as the inner expression. Use the corresponding documentation as a reference for JQL and S-JQL.

The embedded queries are calculated separately from the Expr formula they are used in. Therefore, you cannot use any values from the Expr formula inside a JQL or SJQL query or vice versa. Also, you cannot check the query match for any other item except the one the formula is being calculated for.

In other words, the only data that is passed between an embedded query and the outer Expr formula is 1 or 0 depending on whether the current item matches the query.

Using S-JQL in Generators and Transformations

An S-JQL query usually depends on the structure it's being calculated for. So, similar to Aggregate Functions, when you use a formula with an embedded S-JQL in a generator or a transformation, the query will be applied to the underlying "preceding" structure, that exists before the generator is applied. 

S-JQL Query Performance

Structure optimizes the calls to embedded queries. A query will be run only once for multiple items that the formula is being calculated for, and the result will be checked separately in the calculations for each row.

That said, the JQL itself may potentially be an intensive calculation, if it uses JQL functions or historical conditions like WAS. Please be careful when trying this JQL in a formula, and watch for how long the value is being calculated before publishing the formula for other users. Normally, calculating a "heavy" formula should not prevent users from doing other things in Structure (including using other columns with formulas), but it can place some stress on the Jira server.

Please avoid using the structure() JQL function in JQL or S-JQL that is being embedded in a formula.