Forums

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

How to create an automation rule that compute the average of a custom field of all linked work items

Saif Allah AZZAZA July 9, 2025

Hello folks,

We have set up a custom field (number) for work item type. My aim is to create an automation rule the compute the avergae of this field for all linked work items. I  tried to used this formula but i running in errors:

formula: {{#=}}{{lookupIssues("issue in linkedIssues({{issue.key}})").customfield_10065.sum()}} / {{lookupIssues("issue in linkedIssues({{issue.key}})").size}}{{/}}

error: 

Unable to render smart values when executing this rule:
Failed to get value for lookupIssues("issue in linkedIssues({{issue.key: {{#=}}{{lookupIssues("issue in linkedIssues({{issue.key}})").customfield_10065.sum()}} / {{lookupIssues("issue in linkedIssues({{issue.key}})").size}}{{/}}
Thnak

1 answer

0 votes
Bert Dombrecht
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.
July 9, 2025

Hi @Saif Allah AZZAZA ,

I believe the error is caused by the way you constructed the lookupIssues part.
As far as I know, you need to add a "Lookup work items" action first, and then reference the result of the query as {{lookupIssues}} in a later step.

I have broken the rule down into separate steps and logged each step to validate:

1. Get the work items
Returns the list of the trigger issue and it's linked issues, to be referenced later as {{lookupIssues}}

  • Action: Lookup work items
  • Query: key = {{issue.key}} OR issue in linkedIssues({{issue.key}})

2. Count the work items
Returns the number of items in the list.

  • Action: Create variable "itemCount"
  • Smart value: {{lookupIssues.size}}

3. Sum the custom field 
Returns the sum of the number field.

  • Action: Create variable "itemFieldSum"
  • Smart value: {{#=}}{{lookupIssues.customfield_10065.sum}}{{/}}

4. Calculate the average

  • Action: Create variable "itemFieldAverage"
  • Smart value: {{#=}}{{itemFieldSum}} / {{itemCount}}{{/}}

---

Once the separate steps are validated, you can make this more compact in two steps:

1. Get the work items

  • Action: Lookup work items
  • Query: key = {{issue.key}} OR issue in linkedIssues({{issue.key}})

2. Calculate the average

{{#=}}{{#=}}{{lookupIssues.customfield_10065.sum}}{{/}} / {{lookupIssues.size}}{{/}}

 

I hope this helps

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events