Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,359,907
Community Members
 
Community Events
168
Community Groups

Issue smart values not accesible inside listed values loops

I am retrieving some Jira issue from a remote system via REST API and then iterate the comments.

Inside the comments loop, I can read the updated field and I want to compare this field with an issue field value (such as last sync date and time) but apparently, no issue field values can be accessed from within the listed loop.

Nor even a custom-defined smart value can be accessed there. So I am missing a way to compare the comments times and then pick only those more recent than my last sync date and time field.

Even with this fixed, I am still unsure if an IF condition can be applied inside such loop.

Does anyone have an idea how to pick only most recent comments from an issue retrieved by API using smart values?

image.png

2 comments

Hi @Richard Vencu 

Did you see this post, which shows at the end an example to get the latest comment using the REST API?

https://community.atlassian.com/t5/Jira-questions/How-do-I-get-the-latest-comment-via-REST-API-call/qaq-p/1113527

Best regards,

Bill

Thanks. I know how to get the REST API response. My problem is that I am inside automation rule and I do not have programmatically access to the JSON response but merely the smart values exposed by the automation

There are smart values that allow reading inside a loop (when a list of objects is retrieved). However it seems that inside that loop the parent context is lost and I cannot use existing parent variables to compare with variables inside the loop.

So I am searching for a master of smart values here :)

Thanks, @Richard Vencu 

Perhaps if you post an image of your current rule that will help people give you ideas.  For example, techniques to work-around some of the context/scope issues for information access within a rule with techniques like created variables, custom fields, or entity properties.

Is the image above. So whiile iterating the comments from the rest api call, I would like to add a test clause with IF smart value and compare the comment timestamp with a variable that is declared before the loop, in this form {{threshodlTimestamp}}

The problem is that before the loop i.e. before {{#webhookResponse.body.fields.comment.comments}} I can display the variable value, it is visible, Inside the loop the variable is not existent.

Of course if I replace {{threshodlTimestamp}} with a hardcoded timestamp value it works. I can even make a relative timestamp to now such as {{now.minusDays(5)}} and get only the last 5 days comments but this would force me to run things on a schedule. It is feasable but also increases the load.

So I am only complaining why a variable or a field value from the context issue is not available inside a loop of data fetched via REST API call. Maybe the developers can enlighten us here...

Yes, that is a known problem (design choice) that operators and functions do not work inside of the iterators. I submitted a defect on Cloud version and support said, "by design".

The only work-arounds I have seen were to use a created variable (for single values) or to pre-compute the value in a custom field (for multiple values).

Like Richard Vencu likes this

Using a custom field would be an acceptable solution for me, if it works. I will give it a try. Thanks.

Like Bill Sheboy likes this

Hey @Richard Vencu,

I came across this same issue. Did you fix it using the custom field work around ? I'm not really sure how that can be possible. I'm also calling a REST API and would like to filter out a single object from an array based on an issue field value. I'd be nice if you can share your result on this.

Thanks.

Hi @Muhammad Azzazy  -- Welcome to the Atlassian Community!

Two of the automation improvements since this post was created may help:

With those two things, you may be able to set a created variable before the loop and then use it to filter the list.

Kind regards,
Bill

Like Muhammad Azzazy likes this

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Jira Software

An update on Jira Software customer feedback – June 2022

Hello Atlassian Community! Feedback from customers like you has helped us shape and improve Jira Software. As Head of Product, Jira Software, I wanted to take this opportunity to share an update on...

4,980 views 18 31
Read article

Atlassian Community Events