{{#webResponse.body.values}}{{#items}}{#if(equals(fromString, "In Progress"))}}{{/}}{{/}}{{/}}
How to get created property from values when fromString property is matched inside items?
Use example response from /rest/api/3/issue/{issueKey}/changelog api
The suggestion you got from the other tool is not correct; there is a limitation for the long-format of smart values iterators: once inside the iterator, only data from that scope and lower is visible.
For your scenario, the created attribute cannot be "seen" once inside the {{#items}} ... {{/}} iterator as it filters to that scope.
One workaround is using the inline iterator and the match() function rather than a nested, long-format iterator. For example:
{{#webResponse.body.values}}
{{#if(items.toString.match("^(In Progress)").size.gt(0))}}
{{created}}
{{/}}
{{/}}
Please note this could return multiple created values for the changelog entries, so decide how you want to handle that...such as adding delimiters and parsing the results.
Also, it appears you are doing this for the Status field entries in the changelog, so perhaps instead use the Bulk Fetch Changelogs endpoint as that allows filtering by the field(s):
Kind regards,
Bill
Hi @Bill Sheboy ,
This API helped me to improve my logic. Thanks for sharing it. I had one more question on the created date. The bulk fetch changelog api was returning created": 1689316751665.
Below is example response
How can I convert that to jira dates so that I can update the same in date field? Tried all functions from jira dates but that did not worked https://support.atlassian.com/cloud-automation/docs/jira-smart-values-date-and-time/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That endpoint returns the UNIX timestamp (from the start of day on 1 Jan 1970). And thus the number could be added to that date / time to get the value.
When you expect the changelog to have lots of entries and the Status change is not in the first 100 of them, use this approach with the bulk changelog endpoint.
When you believe there are fewer changelog entries, another approach is continuing to use your original issue get endpoint with the changelog parameter and add the filter for the Status field:
{{#webResponse.body.values}}
{{#if(and(items.toString.match("^(In Progress)").size.gt(0), items.field.match("^(status)").size.gt(0)))}}
{{created}}
{{/}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Its working now with
{{apochDate.toDate.plusMillis(firstInProgressDate.asNumber)}}Where
apochDate = {{now.withYear(1970).withMonth(1).withDayOfMonth(1).withHour(0).withMinute(0).withSecond(0).withMillis(0).convertToTimeZone("UTC")}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Well, done! You could also use this expression for the Epoch date / time:
{{now.withYear(1970).withDayOfYear(1).toDateTimeAtStartOfDay}}
And, if my suggestions helped, please consider marking this question as "answered" to help others with a similar need find solutions faster. Thanks!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Got following suggestion from Handlerbars but it was not working in jira smart values in automations
{{#webResponse.body.values}}
{{#items}}
{{#if(equals(toString, "In Progress"))}}
{{../created}}
{{/}}
{{/}}
{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.