Is it possible to do calculation with the values of Select Lists to generate a computed result?

Olivier Brzozowski December 2, 2011

For example,

A risk is rated 1-5 on criteria A using a custom field (Select List).

The same risk is rated 1-5 on criteria B using a custom field (Select List).

The same risk likelihood is rated 1-5 using a custom field (Select List).

Finally, Jira calculates the final risk exposure by calculating (value A + value B)*likelihood.

Is there a way to do this in Jira?

3 answers

1 accepted

0 votes
Answer accepted
AndreyevM December 3, 2011

This need to be real-time?

The easyest approach i see is set a batch job using JIRA CLI, or a bit hardest thru JIRA's API...

Remember that write a plugin include keep it up-to-date thur JIRA's versions.

HIH!

Olivier Brzozowski December 5, 2011

No it would not have to be real time.

Unfortunately I don't have the skills to develop my own plugin or to use JIRA CLI... could anyone help with that? Is there a way to check if it would help other users?

Thanks,

Olivier

AndreyevM December 6, 2011

As said before, I think that the easyest way to achive this is thru JIRA CLI. It only require a basic shell-scripting skill. I've done a pretty simple example below.

In my setup I create 3 number fields: 'field a', 'field b' and 'field c'. I will sum values of 'field a' and 'field b' and store it in 'field c'. Innitially they have these values:

$ ./jira.sh -a getIssueList --filter 'my filter' | grep -Eo 'TST-[0-9]+' | while read i; do for j in a b c; do ./jira.sh -a getFieldValue --issue $i --field "field $j"; done; done

Issue TST-2 has field 'field a' with value:

'231'

Issue TST-2 has field 'field b' with value:

'111'

Issue TST-2 has field 'field c' with value:

Issue TST-1 has field 'field a' with value:

'1'

Issue TST-1 has field 'field b' with value:

'1'

Issue TST-1 has field 'field c' with value:

Now I will run a saved filter which gave me a issue list and, to each issue, store value of 'field a' in a temp variable 'a', store value of 'field b' in a temp variable 'b', store the sum of variables 'a' and 'b' in 'field c' and then show 'field c':

./jira.sh -a getIssueList --filter 'my filter' | grep -Eo 'TST-[0-9]+' | while read i;

	do	a=$(./jira.sh -a getFieldValue --issue $i --field 'field a' |tail -1 | grep -Eo '[0-9]+');

		b=$(./jira.sh -a getFieldValue --issue $i --field 'field b' |tail -1 | grep -Eo '[0-9]+');

		./jira.sh -a setFieldValue --issue $i --field 'field c' --values $(($a+$b)) ;

		./jira.sh -a getFieldValue --issue $i --field 'field c';

done

The output looks like:

Issue TST-2 updated.

Issue TST-2 has field 'field c' with value:

'342'

Issue TST-1 updated.

Issue TST-1 has field 'field c' with value:

'2'

Of course, there are a lot of improvemnts to do on this to use in production env. But I think this is a start.

HIH!

0 votes
BMueller January 1, 2013

I have the same issue - I'm trying to use a calculated field, but the misc custom field thinks that the select list items are strings. When I add them together, I get a concatenated number not an added number.

For example, add together current rating plus proposed rating.

(A)Rating + (B) Rating

If (A) = 1 and (B) = 2, the answer should be 3

The calculated field delivers 12 as the answer!!!!

Any advice?

0 votes
JamieA
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.
December 3, 2011

Write your own calculated custom field type plugin...

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events