Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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

1 comment

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

Comment

Log in or Sign up to comment
TAGS
Community showcase
Published in Bitbucket

⭐ Calling all Bitbucket and DevOps experts: Special showcase opportunity ⭐

Hi, Bitbucket community! Are you a DevOps practitioner (or know one in your network)? Do you have DevOps tips, tricks, or learnings you'd like to share with the community? If so, we'd love to hea...

41 views 3 1
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you