Calculate number based on single select options

CCP TechOps December 1, 2014

We have two single select fields with options like cf1val1, cf1val2, cf2,val1, cf2val2 and so on. I have a 3rd custom field as Calculated number field. On this number field I want numbers based on selection of the two field options.

Assume values as mentioned below

cf1val1 & cf2val1 - 1

cf1val2 & cf2val2 - 2

 

When cf1val1 & cf2val1 are selected, the calculated number field should have value 1*1=1

When cf1val1 & cf2val2 are selected, the calculated number field should have value 1*2 =2

 

I tried with formula as mentioned below, but could not get the output. No luck.

<!-- @@Format:
if ( (issue.get("customfield_23141").getValue().equals("cf1val1")) && (issue.get("customfield_23142").getValue().equals("cf2val1")) )
return 1;
if ( (issue.get("customfield_23141").getValue().equals("cf1val1")) && (issue.get("customfield_23142").getValue().equals("cf2val2")) )
return 2;
-->

 

Also in logs i get this error "[innovalog.jmcf.fields.CalculatedNumberField] CalculatedNumberField: could not find formula in custom field description" even though I put the above formula in description of the calculated field. Kindly help on this.

2 answers

1 accepted

1 vote
Answer accepted
David Fischer
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 2, 2015

The formula needs to be put in the field description, not field configuration description. You need to choose edit, not configure in the field actions pop-up menu. 

CCP TechOps January 12, 2015

Awesome. It worked. Thanks a bunch for your help.

0 votes
David _old account_
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 1, 2014

I'm afraid you confused @@Format with @@Formula. You want the latter. 

David 

CCP TechOps January 2, 2015

David, I changed it to @@Formula still did not get the required outcome. I am not able to see the field on view screen when the issue is created. I double checked and confirmed that it is configured in the screen. Also I tried below code and the same did not work too. Please let me know if any modifications need to be done and suggest the same over here. <!-- @@Formula: Object cf1 = issue.get("customfield_23141"); Object cf2 = issue.get("customfield_23142"); int mult = 0; int nult = 0; if( cf1 != null && !cf1.toString().equals( "cf1 value1" ) ) { mult = 1; } if( cf1 != null && !cf1.toString().equals( "cf1 value2" ) ) { mult = 2; } if( cf2 != null && !cf2.toString().equals( "cf2 value1" ) ) { nult = 1; } if( cf2 != null && !cf2.toString().equals( "cf2 value2" ) ) { nult = 2; } int number = mult * nult; return number; -->

David _old account_
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.
January 2, 2015

Did you look inside altiassian-jira.log for errors? Search for "innovalog". Also, what do you mean by "view screen when the issue is created"? Do you mean on the Issue Creation screen or on the view screen after you've created the issue?

CCP TechOps January 2, 2015

Yes I am not able to view the calculated field on the view screen which we get after the issue gets created. Yes I looked into the logs and found below errors same as mentioned in description. 2015-01-03 00:43:08,391 http-17000-23 WARN ikkhan 43x4803x1 1xozqbn 10.19.0.17,10.253.96.191 /browse/IKK-34 [innovalog.jmcf.fields.CalculatedNumberField] CalculatedNumberField: could not find formula in custom field description 2015-01-03 00:43:08,404 http-17000-23 WARN ikkhan 43x4803x1 1xozqbn 10.19.0.17,10.253.96.191 /browse/IKK-34 [innovalog.jmcf.fields.CalculatedNumberField] CalculatedNumberField: could not find formula in custom field description I have put in above formula in Custom field description in "Field Configuration".

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events