I want to get the latest version change record from the jira cloud system audit log to get the old version name and the new version name for further automation for a 1-way sync of release versions (create, update, delete) to another project.
When I use a web request block in the automation to get the audit log record I'm looking for it looks like this:
{
"offset": 0,
"limit": 1,
"total": 1286,
"records": [
{
"id": 18896,
"summary": "Project version updated",
"remoteAddress": "000.000.000.000",
"authorKey": "0a",
"authorAccountId": "0a",
"created": "2024-01-31T07:58:21.296+0000",
"category": "projects",
"eventSource": "",
"objectItem": {
"id": "10341",
"name": "C-0.0.0",
"typeName": "VERSION"
},
"changedValues": [
{
"fieldName": "Name",
"changedFrom": "C-0.0.3",
"changedTo": "C-0.0.0"
}
],
"associatedItems": [
{
"id": "10014",
"name": "Sandbox CONTXT",
"typeName": "PROJECT"
}
]
}
]
}
The values I'm trying to access, I would expect to access by:
However these produce no value when logging them in automation.
I am able to get a single value array using the following, but this doesn't help me as I still can't access the single value in the array as a string:
I get values like this:
Then trying to access these values something like set it to a smart value, {{value.get(1)}} returns nothing when logging it with the automation.
How can I access the values as strings like the following?
I am currently using the Free license of Jira Cloud, and so have no access to the audit logs to test my suggestions...
That web response appears to contain an array, and not a list of values. This would explain why the get() function is not working as you expect.
You could try grabbing the records and then using a match() with a regular expression on that, progressively parsing to get the values. https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/#match--
Kind regards,
Bill
Hi @Bill Sheboy
After unsuccessfully trying with match per your suggestion I went back to get() again. The syntax that ended up working for me to access the fields were as follows:
With those pulling directly from the webrequest (example JSON in my first post) it appears to be working.
It is bizarre to me that the correct json syntax doesn't work though. I am accessing an array of objects nested inside another array of objects so I'd expect it to be {{webResponse.body.records.get(0).changedValues.get(0).changedTo}} but that doesn't work.
get(0) only seems to be needed on the nested array for some reason, even though they are both arrays of a single object.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
That is curious...
Have you tried any tests with multiple items in both records and changedValues to confirm the correct item is returned with only one get() call at the end?
In my experience, other automation rule, smart values which return lists AND have returned only one item seem to alias (or collapse data structures) such that the child attributes work as if there was no list. For example:
{{issue.sprint.name}} versus {{issue.sprint.first.name}} versus {{issue.sprint.get(0).name}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I haven't since in this case I didn't need more than one item in the array since I searched for only the latest change. Could be a risk though seeing the rule I put this into can take up to 19 seconds to complete running and the delays in jira automation executions I've been seeing it might be smart to expand the audit log search to grab more results and look for only the one I need. Will have to come back to this when time permits, thanks for the recommendation.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Can you share the end point you are using, I never used it and so dont know response structure... but curious, can you log below smart value to see if anything is getting returned.
{{#webhookResponse.body.records}}{{#changedValues}}{{#if(equals(fieldName,"Name"))}}{{#first}}{{changedFrom}} {{/}}{{/}}{{/}}{{/}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Kalyan Sattaluri you can find the endpoint here: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-audit-records/#api-rest-api-3-auditing-record-get
Any changes made in the jira site will be logged here, so you can capture version change events since atlassian doesn't provide any smartvalue for these.
Thanks for the suggestion, I can never get that syntax down right. I actually solved this a different way.
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.