Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Jira Automation - Filtering for "Overdue" versions from REST api response

Kalyan Sattaluri June 13, 2023

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 in this thread said: "if there is a specific one you need, such as by name filtering...Unfortunately smart value, list filtering 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!!

 

1 answer

1 accepted

1 vote
Answer accepted
Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 14, 2023

Hi @Kalyan Sattaluri - 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) 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 but we didn't see documentation for it until 01/Jan/2022.

Now, last June (2022), Bill referenced the original announcement of the feature by @Sam Harding from Atlassian, on 06/Oct/2021.

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

Kalyan Sattaluri June 16, 2023

hi @Darryl Lee 

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!

Darryl Lee
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 16, 2023

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.)

Kalyan Sattaluri June 17, 2023

WOW. Awesome.

Thank you very much @Darryl Lee . 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.

Like Darryl Lee likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events