Forums

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

calculating difference between two number field using Jira misc custom field

Abhishree Nagesh
Contributor
December 18, 2018

Hi

i am using jira misc custom field, So code is needed to find the difference between two number custom field.

i have 3 custom field of number field(time estimated,time consumed and time remaining)

so when ever i enter the time estimated and time consumed ,automatically time remaining must be calculated(i.e time estimated-time consumed=time remaining)

Regards,

Abhishree nagesh

1 answer

1 accepted

0 votes
Answer accepted
Patrick Cartier [Candylio]
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 18, 2018

Hi @Abhishree Nagesh,

There is an example here in the documentation for addition, I think you can use the same for subtraction.

https://innovalog.atlassian.net/wiki/spaces/JMCF/overview#JIRAMiscCustomFields-calculatednumberfield

Keep in mind that for time you might have to alter the formula a bit since Jira counts in milliseconds

Abhishree Nagesh
Contributor
December 18, 2018

Hi,@Patrick Cartier [Candylio]

I have tried the same code for finding the difference, which is suggested in the document but it's not working.

So kindly help me with the relevent code.

 

Regards,

Abhishree Nagesh

Abhishree Nagesh
Contributor
December 18, 2018

Hi@Patrick Cartier [Candylio]

Thanks for your quick replay but the code is not working for addition also.

 

Regards,

Abhishree Nagesh

Patrick Cartier [Candylio]
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 18, 2018

Hi @Abhishree Nagesh,

Please show me what you have so far and I will take a look.

edit: also please make sure that the two source fields are number fields if you are using a "calculated number field" in the resulting field.

Abhishree Nagesh
Contributor
December 18, 2018

@Patrick Cartier [Candylio]

I have used the below code, with respective custom field ID's of time estimated and time consumed and updated in description of the calculated number field (remaining time) and trying to extract from the gadget using board filter.

(issue.get("customfield_10114") != null ? issue.get("customfield_10114") : 0) + (issue.get("customfield_10150") != null ? issue.get("customfield_10150") : 0)

Regards,

Abhishree Nagesh

Patrick Cartier [Candylio]
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 18, 2018

The formula looks good.  Three possible situations I could think of:

1.  are the two fields of time estimated and time consumed number fields?

2.  Don't forge to add "<-- @@Formula:" before and "-->" after

3.  Make sure you are putting the formula in the description of the calculated field, not the description of the field configuration.

Should look like this in the end (depending on your custom fields):

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

 

Abhishree Nagesh
Contributor
December 19, 2018

@Patrick Cartier [Candylio]

1. Yes, time estimated and time consumed are the number field.

2. i have put the code as shown with respective custom id's.

3. i have put the code in description of calculated field.

but its not working.

Regards,

Abhishree Nagesh

Abhishree Nagesh
Contributor
December 19, 2018

@Patrick Cartier [Candylio]

Thanks for your time, the other code from the document has worked.

 

Regards,

Abhishree nagesh

Patrick Cartier [Candylio]
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 19, 2018

This formula works for me.  Without seeing screenshots or anything else I can't help you.  Sorry.

<!-- @@Formula:

( issue.get("time estimated") != null ? issue.get("time estimated") : 0 ) -
( issue.get("time consumed") != null ? issue.get("time consumed") : 0 )

-->

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events