Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Using .get() to access a value within a list of dictionaries in a Jira automation rule

Rachel Alexander
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 13, 2025

Hi,

I am new to using Jira automations, and I am trying to use a Webhook-triggered automation rule to populate custom fields of a sub-task using the json sent through.

Each json sends a list of dictionaries (within "results") and I need to:

For each dictionary, populate the custom fields using the attributes list of dictionaries as highlighted in bold the example below:

payload = {
"event": "xxx",
"checkResults": [
{
"id": "xxx",
"name": "xxx",
"attributes": [
{
"id": "xxx"
"name": "xxx"
"label": "xxx"
"value": ["value1"]
},
{
"id": "yyy"
"name": "yyy"
"label": "yyy"
"value": ["true"]
},
{
"id": "yyy"
"name": "yyy"
"label": "yyy"
"value": ["true"]
}
],
"outcome": "pass"
},
{
<<<<<dict no. 2>>>>
}
}

So far, my rule creates a smart value called "checkResult" which represents each dictionary within the "checkResults" list shown above (assume dict no. 2 is the same as the first one).

Jira Webhook automation.png

Here is a look into the Create Subtask action:Screenshot 2025-05-13 at 16.17.10.png

So currently I am using .get(0) and .get(1) to get attributes xxx and yyy. I was wondering if I could use some sort of logic like custom_field_x = "value" where "name" = "xxx". However, I cannot nest another loop within the "For each checkResult list item" branch.

Please let me know if I need to provide further explanation 😅 Many thanks in advance!

1 answer

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 13, 2025

Hi @Rachel Alexander -- Welcome to the Atlassian Community!

For automation rule questions, context is important for the community to help.  Please post the following:

  • an image of your complete automation rule in a single image for continuity
  • images of any relevant actions / conditions / branches
  • an image of the audit log details showing the rule execution

Until we see those...

 

You describe this:

So far, my rule creates a smart value called "checkResult" which represents each dictionary within the "checkResults" list shown above...

How are you creating that smart value: with Create Variable, with Create Lookup Table, etc.?

 

If you are parsing the results directly, you can nest iterators, such as from the {{webResponse}} to dynamically build your JSON expression for creating the Subtask:

{{#webResponse.body.checkResults}}
{{#attributes}}
...use the attributes to dynamically build the JSON
{{/}}
{{/}}

I recommend building that first and storying in another Created Variable to help with logging and testing.

 

If you are using a Lookup Table, you could use the entries function to help iterate what has already been parsed.  Please review this article to learn more about that technique: https://community.atlassian.com/forums/Automation-articles/Update-Create-lookup-table-action-improvements/ba-p/2427798

 

Kind regards,
Bill

Rachel Alexander
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
May 14, 2025

Hi Bill,

Thanks for the quick response!

Apologies, when I tried to insert images in the original message, there was an issue with the character limit. I realise now its because I copied and pasted the images in, so I've amended the original message 😅

I created the variable within the For each: Smart Value action. Is this the best thing to do? It also doesn't seem to run through all of the dictionaries, so maybe this is the root of that issue as well...

When you say dynamically build the JSON expression, what action would I put this in, or would this be in the Created Variable?

Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 14, 2025

Thanks for that additional information!

 

First, I note your JQL condition is using single-rather than double-quotes.  I recommend changing those to avoid problems; I believe JQL is documented only supporting double-quotes.

 

Next, if I understand your scenario correctly, the "attributes" each contain:

  • a "name" which is a custom field ID
  • a "value" which is the desired value for the above field

And so in the Create Issue action, you may use dynamically-generated JSON from iterating the values.  I am assuming the custom fields are all single-select options.

To avoid timing problems, create the dynamic JSON in a variable first, perhaps writing it to the log to confirm the structure.

  • action: create variable
    • name: varJson
    • value:
{
"fields": {
{{#checkResult.attributes}}
"{{name}}": { "value": "{{value}}" } {{^last}}, {{/}}
{{/}}
}
}

Then use that variable as the JSON for the create as: {{varJson}}

The key to making this work is getting syntax correct for your specific, custom field types.

 

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events