Can Automation for JIRA calculate a field on a linked issue using math functions as action?

Nadine August 22, 2017

I am currently working on the challenge to implement project controlling in JIRA and was wondering whether a field on an issue called project could automatically be calculated when a value on a linked sub-project issue changes?

I have a hierarchy over four levels using sub-tasks already so changing the link between project and sub-project to a task-sub-task-relationship is not an option.

5 answers

1 accepted

1 vote
Answer accepted
andreas
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.
August 23, 2017

Hi Nadine, 

I'm not 100% sure I fully understand your exact setup, but with Automation for JIRA, you can action related issues that you find based on JQL. Match functions can be applied to those.

 

So for example you could have a rule like this:

  • Trigger: Field value changed with your field selected
  • JQL condition: type = sub-task ?  
  • Branch rule with Parent
    • Edit issue action where you set the 'project' field to something like:
      {{#=}}{{triggerIssue.someField}} + 25{{/}}

'triggerIssue' would refer to the issue produced by the trigger in this example. 'someField' is the name of your field.

Not sure if this helps.  Like I said I need more details about your exact case.    Bacially in the branch rule, you could also use JQL to find the related issue somehow.  

Cheers,

  Andreas

Nadine August 23, 2017

Hello Andreas 

Thanks a lot for your prompt reply.

Actually, I'm not sure I fully understand my setup... ;-) but let me try to explain: 

I have a standard issue type project linked to 1-n other standard issue types sub-project via the link has sub-project.  Both issue types have a numeric field called Labour Hours and what I need to achieve is the Labour Hours for issue project being automatically updated as sum of Labours Hours of all linked sub-projects when Labour Hours of one sub-project is updated. 

I have already configured a prototype using tranistion triggers and post-functions for calculations which works fine. But now my customers wants values to be updated not using transitions. We could use Script Runner or a custom add-on to achieve this but I prefer a solution not requring to much scripting which is also maintained as a marketplace add-on. Hence, I would love to use Automation for JIRA.

andreas
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.
August 23, 2017

Hi Nadine,

Ah right so you want to calculate the aggregate sum of various linked issues.  We don't support this yet, but we're already tracking this request at https://codebarrel.atlassian.net/browse/AUT-476.

We've got quite a few higher priority items in our backlog at the moment so it will be a while before we can get to this, but we'll let you know when we get a chance to work on this.

Cheers,

  Andreas

Étienne Borella October 30, 2017

Hi

We have the same scenario that we'd like to address.

Our hierarchy of issues is made of Epics / Stories / Subtasks.

We'd like to have a "Rolled Up Time Spent" custom field that sums up the time spent on a issue with the total time spent on related issues below when time is logged against either the task itself or its related issues.

e.g. when time is logged on a subtask (or the subtask is edited), "Rolled Up Time Spent" is updated at the parent Issue & the Epic levels (may be a cascade of 2 automations here, due to the 3 levels hierarchy).

I don't seem to be able to login and vote for AUT-476, so I add this comment here to say that I am interested ;-)

Thanks

Lorraine Gorman January 3, 2018

Hi

We are currently evaluating Automation for JIRA for our needs.  This is a very important feature for us as well, especially now that the JIRA pricing structure has changed significantly.  We will need  to minimize the number of add-ons we purchase.  I'm not sure if there is way to vote up on this but consider this as high priority if you can.

Thanks.

4 votes
Patrick Haley January 13, 2022

This is for people who find this in the future. I was able to set up a Jira Automation to calculate a value.

Trigger: Montior field values for changes.

Then I created Variables using Smart Values for each of the custom fields I created.

smart.png

Once I had all of the variables defined, the final automation component was an Edit Issue field. I had set up a custom view only field so that it couldn't be edited directly by users. I used Andreas formula in the accepted comment which worked perfect for me. 

{{#=}}({{Reach}} * {{Impact}} * {{Confidence}}) / {{Effort}}{{/}}

final.png 

Steve Letch February 28, 2022

Very nice, I really wish they'd port over all these nice functions to the server/data center versions :(

Like Artur Franczuk likes this
0 votes
mahi kamal January 22, 2023

hi , can i use automation and make formula with custom field? if i can..could you please help me?

Patrick Haley January 22, 2023

Yes it’s possible. See my previous reply in this thread for more info.

Like mahi kamal likes this
mahi kamal January 22, 2023

thank you for explain..but i have problem could you please help me?sx 1_23_2023 10_05_52 AM.png

Patrick Haley January 23, 2023

I think it's because you're using an If/Else statement, but it doesn't contain an action when the first If matches. 

You're basically saying:

IF custom_field_11225 is not empty

          THEN do nothing <-- This is what is causing the issue

IF custom_field_11226 is not empty

          THEN edit issue fields

 

If the first IF statement does not have an action and all you're doing is checking if that field isn't empty before the next IF statement, consider using an Issue fields condition instead.

2023-01-23_19-14-20.png

Like mahi kamal likes this
mahi kamal January 23, 2023

thanks a lot my friend you good explained to me.

now i have another question if you can answer me i really appreciate

i want calculate to formula this 100-(responsetime - ticket count * 360 / 60 * 5 ) and i want write in custom field so i write smart value like this =>

  {{#=}}100-{{issue.customfield_1112}}-{{issue.customfield_1113}}*360/60*5{{/}} 

and have error could you please help me about this again? thank you so much

mahi kamal January 23, 2023

 i want calculate the formula and whats the type of custom field  when calculate formula?

jun lee February 19, 2023

@Patrick Haley  I want to calculate custom fieild by 

I want to make an automation rule like below.

when : issue linked

condition 1 : linked id = 10309, 10703

condition 2 : issue type id = 10511, 10612, 10603

condition 3 : linked issue status = completion

issue edit : (number of condition1 & condition2 & condition3) / (total number of condition1) x 100

 

How to calculate (number of condition1 & condition2 & condition3) / (total number of condition1) x 100?

If it is not possible, can I calculate (number of completed linked issue) / (total linked issue)  x 100 ?

mahi kamal February 26, 2023

i solve my problem we have to use {{#=}} and at the end of use {{\}} and during formula use ( ) its too much important .

this is my formula:

{{#=}} ( {{issue.customfield_11237}} * 50 ) / {{issue.customfield_11238}} {{/}}

0 votes
mustafa korkmaz September 13, 2020

+1

0 votes
Piotr Zolnierek February 22, 2019

+1

Suggest an answer

Log in or Sign up to answer