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?
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
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Using a custom field would be an acceptable solution for me, if it works. I will give it a try. Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you see this post, which shows at the end an example to get the latest comment using the REST API?
Best regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.