Chaining Filters in a Jira Expression

When creating a Jira Expression for a SIL Validator in Jira Cloud, how would you create an expression any more complicated than checking an issue type? Use a filter function!

Instructions

Before getting started, create a SIL script which tests Jira Expressions via Atlassian’s REST API.

For an introduction to filters, see this article.

For chaining functions, see this article.

The use case for our example is to create a validator where a Story cannot be closed until all linked Tasks are closed.

 

  1. First we test the the current issue is a Story. Our first Jira Expression would look something like the following:

    issue.issueType.name == \"Story\"


    When placed in the JSON for the expression tester:

    { "expression": "{ expressionTest: issue.issueType.name == \"Story\" }", "context": { "issue": { "key": "DEMO-1" } } }

     

  2. Next, we create a filter to find all linked Tasks. Here is the expression to test:

    issue.links.filter(linkedIssue => linkedIssue.inwardIssue.issueType.name == \"Task\")


    Here is the JSON for our tester:

     

  3. In our last test, we chain the filter from step 2 to the .every() function that checks that every link returned from the filter has a “Done” status.


    Again, the JSON for our tester:

     

When we combine the expressions from above and remove the escaped characters, our Jira Expression for the SIL Validator would look something like the following:

Filter by label

There are no items with the selected labels at this time.