Calculated Number Field update

peter novak
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 15, 2012

hello, in one transition i am setting value of "last time duration" (in minutes, i.g. 10) and i would like to update Calculated Number Field "TOTAL" - add last time to TOTAL ... but when i reffer in formula to itself, it doesnt work ...

<!-- @@Formula: (issue.get("customfield_10600") != null ? issue.get("customfield_10600") : 0) + (issue.get("customfield_10602") != null ? issue.get("customfield_10602") : 0) -->

//id of TOTAL is 10602, id of last time is 10600 ...

thank you

9 answers

1 accepted

0 votes
Answer accepted
peter novak
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 16, 2012

ok, i figured it out:

i have Calculated Number Field called "Total time" from plugin JIRA Misc Custom Fields. Next i have Number field "null" and Number field "last time". In transition "Add last time duration to total time" i am entering value in field "last time". In create transition i am copying valu from "total time" to "null" ---- this is my way of setting null field to value 0, because calculated number field has default value 0 if all others fields are ot defined, that i am add together in description of the Calculated number field. Next i am using number field "last value".

Description of "total time":

<!-- @@Formula: (issue.get("customfield_10600") != null ? issue.get("customfield_10600") : 0) + (issue.get("customfield_10604") != null ? issue.get("customfield_10604") : 0) -->

//id for "last value"=10600, id for "last time"=10604

The clue to achieve the result (to add a value to total counter) is in transition BEFORE entering value of "last time" execute this copying: last value := total time AND last time:= null.

Simply solutions are the best :)

0 votes
DeepakBhatia August 20, 2012

Hi Peter Novak,

I have still not figured out the issue, I am doing exactly same given by you.

Regards

Deepak

peter novak
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 20, 2012

hi

you need three variables: variable "null" with value 0, variable "old_value" and variable "add_this_value" -- these variables are Number Fields. Now you need Calcuted Number field "Total". In description of "Total" type:

<!-- @@Formula: (issue.get("customfield_10600") != null ? issue.get("customfield_10600") : 0) + (issue.get("customfield_10604") != null ? issue.get("customfield_10604") : 0) -->

10600 is ID for field "old_value" and 10604 is ID for field "add_this_value".

1. in create transition use post script Copy value from Field to Field and copy value from "Total" to "null"

2. Now say, you are entering value for field "add_this_number" via screen in "transition1". Before traansition1 you need to add post script (to transition0) that will Copy value from Field to Field: old_value := Total AND add_this_value := null;

And thats it :)

0 votes
peter novak
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 15, 2012

and please can you try to give me a hint, how to manage scripting to achieve my goal? this is blocking issue for me right now ...

on some screens (screens associated with transitions between states) i can enter a value for "last duration" and after submitting the screen, i want to add this value to TOTAL duration field ...

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.
August 15, 2012
0 votes
peter novak
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 15, 2012

are you familiar with some other plugin, to get the correct result? sollution, when i need t add one number to total count? thx

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.
August 15, 2012

OK... sorry, not familiar with that plugin.

0 votes
peter novak
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 15, 2012

p.s.: "but when i reffer in formula to itself, it doesnt work ..." - the resulted value is much more greater than expected, when i am reffering to the same field: A = A + B (A is reffering to itself)

0 votes
peter novak
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 15, 2012

hi jamie, i am using

JIRA Misc Custom Fields1.5.1 where is

Calculated Number Field
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.
August 15, 2012

You are using some plugin, but which one? What language is that?

Suggest an answer

Log in or Sign up to answer