Issue smart values not accesible inside listed values loops

Richard Vencu November 16, 2020

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

8 answers

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 23, 2021

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

1 vote
Richard Vencu December 17, 2020

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

1 vote
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2020

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

0 votes
Muhammad Azzazy December 23, 2021

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.

0 votes
Richard Vencu December 17, 2020

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

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 17, 2020

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.

0 votes
Richard Vencu December 16, 2020

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

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 16, 2020

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

Suggest an answer

Log in or Sign up to answer