Jira Automation - Filtering for "Overdue" versions from REST api response
Asked by Kalyan Sattaluri:

Hi,

I am on Jira Server Automation.

I retrieved all versions for my project using REST api and result looks like what is shared in documentation page : <https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/#api/2/project-getProjectVersions>

I now want to filter this down to ones which are overdue. ("overdue": true,) because I need to send an email of all overdue versions, their name and release date for folks to take action.

Going through documentation, I think response is a list and can be accessed thru {{webhookresponses.body}} but I cant figure out how to filter this list.

[@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) in this [thread](https://community.atlassian.com/t5/Jira-questions/Fill-Affected-Version-with-automation/qaq-p/2054990)said: "if there is a specific one you need, such as by name filtering...Unfortunately [smart value, list filtering](https://community.atlassian.com/t5/Automation-articles/Filtering-smart-value-lists/ba-p/1827588) does not work yet for Data Center/Server. You could use the match() function with a regular expression if you extract from the correct level in the response."

So trying to understand if what I am trying is possible, if so, any guidance is greatly appreciated. I havent made any progress in the if block conditions I tried so far.

Response from API call looks like in documentation. Thanks!!


Answers:
author: Darryl Lee
body: Hi [@Kalyan Sattaluri](/t5/user/viewprofilepage/user-id/5118323) - whoa, you found a rare case of Bill being wrong (albeit on a post from almost a year ago). :-}

Smart list filtering (or as Atlassian calls it [Conditional Logic](https://confluence.atlassian.com/automation/jira-smart-values-conditional-logic-1081351607.html)) definitely works on DC/Server. I have a rule that uses it on our Jira Server (yes I know) instance. I created it back in March of this year.

For the record, this was supposedly done on 30/Aug/2021, per [JIRAAUTOSERVER-294](https://jira.atlassian.com/browse/JIRAAUTOSERVER-294) but we didn't see [documentation](https://confluence.atlassian.com/automation/jira-smart-values-conditional-logic-1081351607.html) for it until 01/Jan/2022.

Now, last June (2022), Bill referenced the original announcement of the feature by [@Sam Harding](/t5/user/viewprofilepage/user-id/3964520) from Atlassian, on 06/Oct/2021.

SO ANYWAYS, yeah, this should be possible. Let us know if you run into any issues!

comments: author: Kalyan Sattaluri
body: hi [@Darryl Lee](/t5/user/viewprofilepage/user-id/664518)

Can you please tell, based on the documentation for versions from above, if what is returned is a list?

All below syntax works:

*

  ```
  {{webhookResponse.body}}? --> prints complete response
  ```

*

  ```
  {{webhookResponse.body.overdue}} --> prints true,false?
  ```

*

  ```
  {{webhookResponse.body.last.overdue}} --> prints false
  ```

*

  ```
  {{#if(equals(webhookResponse.body.last.overdue, false))}} last release is good?{{/}}  --> Correctly prints the statement as expected
  ```

so I am able to access the values.

But when I try to iterate and filter in email, I am not getting my syntax right and need help. Below is what I have tried:

```
{{#webhookResponse.body}}

{{#if(equals(webhookResponse.body.overdue, true))}} 

Version needs to be released

?{{/}}

{{/}}
```

I am trying all combinations of above syntax, used webhookResponses.body. removed reference to webhookResponse.body and just used if statement. etc.

I have searched all over atlassian and could not find a reference so If some one can help, will def help other noob like me.. So any help is greatly appreciated!


author: Darryl Lee
body: Hey there!

You're very close! The trick with filters/conditional logic is that the smart values within them they are always relative to the list you are filtering. So what you want is:

```
{{#webhookResponse.body}}
  {{#if(equals(overdue, true))}} 
Version {{name}} needs to be released
?{{/}}
{{/}}
```

(I also threw {{name}} in there so you can see exactly which version is overdue.)


author: Kalyan Sattaluri
body: WOW. Awesome.

Thank you very much [@Darryl Lee](/t5/user/viewprofilepage/user-id/664518) . It works

It was bugging me for a while and so thanks again for making my weekend!!

Hope others will find this useful as well.