I'm building an automation that triggers when an Insight object is edited, and if 2 specific attributes were edited it will update an attribute of another Insight object.
I need to use the "Send web request" action to make an API call to Insight to pull the objects history, so I can determine what attributes were changed and the previous and new values. This is where I'm running into my problem.
I can use {{webResponse.body}} to look at the object history, and from this community question I figured out I can get specific values from the body by using {{webResponse.body.get(#)}}. E.g. {{webResponse.body.get(0)}} to get the value of the first index.
But is there a way to grab more than 1 value from the array? I.e. How do I grab just the first 2 indexes, or a range of indexes like the 2nd to 5th?
Hi All, Using the .get(#) syntax, I was able to step into a JSON array an grab sub-elements.
{{webresponse.body.incident.custom_field_entries.get(0).custom_field.name}}
Hopefully this helps someone else as this is a real tricky item!
https://support.atlassian.com/cloud-automation/docs/jira-smart-values-lists/
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can even nest the gets:
{{webresponse.body.incident.custom_field_entries.get(0).values.get(0).value_option.value}}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can also iterate over the list like this:
{{#webresponse.body.incident.custom_field_entries}}{{custom_field.name}} {{/}}
Where custom_field_entries is an array of objects.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
This is what you need: https://support.atlassian.com/jira-software-cloud/docs/use-smart-values-to-access-listed-values/
My advise is to invest some hours into smart value docs with some practice. This will give you the ability to realise new use cases without coding.
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.
Hi @Romesh no unfortunately I never did figure this out. I had to shift my focus to some higher priority items, and never got back around to this. I didn't delete the automation rule I was working on as I do want to revisit this, just haven't gotten to it yet. If I do ever figure this out I'll try and remember to let you know.
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.