Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

I want to create a total (sum) for a custom field (Jira Data Center version)

Stuart Wosika
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.
September 11, 2024

Hi guys,

 

  • I have a custom field called "Risk Score" which holds a number
  • This custom field is linked to an issuetype = Risk
  • On triggering of an update to this issuetype
  • I want to get all risks
  • I want to then add up the total for all of the risks "Risk Score"
  • Then use this total to update a field or pass to an email for example

 

So I:

  • I tried to create a branch (For JQL)
    • I tried smart value "lookupIssues" with sum but although I do not get an error when running the rule, sum does not seem to do anything:
      • {{lookupIssues.customfield_11139.sum}}
    • I created a variable to store the total but could not get this to work as could not work out how to update the variable

 

Just trying to do something I thought would be simple.  I must be missing something.  Can anyone help me with an example rule please?

 

1 answer

1 accepted

2 votes
Answer accepted
Stuart Wosika
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.
September 12, 2024

Hi guys, the documentation suggests the following but is not clear.  You cannot use properties such as sum and max with custom fields in a Jira Automation rule (Jira Data Center platform).  There is a ticket open with Atlassian that relates to this issue but even that is not clear on which properties are not supported.

I found another article that identified a possible workaround is to use the ACTION "send web request".   This is where (in my use case) I use the search method (API) and JQL to query Jira via the API.  I have now got this working and I am now able to sum up a field (value) for a number of issues successfully.

 

FYI

 

1. Action : Send web request

2. "Send web request" configuration:

       Webhook URL : https://<your domain>/rest/api/2/search/

       Headers:       Authorization         Bearer <PAT id you have created in Jira>

                            Accept                    application/json

       HTTP Method:   Post

       Webhook Body (custom data):

       {

                   "fields": [

                      "summary",

                      "status",

                      "customfield_11139"

             ],

             "jql": "project=NPR and issuetype=risk"

      }

     

     NOTE: You can use any API call GET or POST.  The above returns all issues of type risk

                for a specific project

3. Now sum up the custom field "Score Risk" which is field customfield_11139.  There are 

   multiple actions where you can do this.  I am showing example using "Send email"

   

   Content:

        Total Risk Score = {{webhookResponse.body.issues.fields.customfield_11139.sum}}

        Complete Payload Response =

                {{webhookResponses}}

 

Hope this helps someone in the future.

 

Regards.

 

Stuart.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events