Calculate number based on single select options

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
Accepted answer

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. 

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

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

David 

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; -->

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?

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
Community showcase
Published Oct 31, 2018 in Marketplace Apps

Marketplace Spotlight: Zephyr

Hello Atlassian Community! Each month, we run a series of Spotlights to highlight Marketplace vendors and apps that our team thinks this Community would find valuable. In last month's Spotlig...

310 views 0 1
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you