It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Calculate number based on single select options

CCP TechOps Dec 01, 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 [Innovalog] Community Leader Jan 02, 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 Jan 12, 2015

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

0 votes
David [Innovalog] Dec 01, 2014

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

David 

CCP TechOps Jan 02, 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 [Innovalog] Jan 02, 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 Jan 02, 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
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Webinar alert! An IT Admin's Guide to Securing Collaboration at Scale

Hello, Atlassian Community! My name is Dave Meyer and I'm a Principal Product Manager at Atlassian. I wanted to give this community a heads up about an upcoming Webinar that might be of interest...

175 views 2 7
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you