Calculated Number field

TCampbell July 21, 2014

Please see the calculated number field we need written below. I would love some help in writing the script to accomplish what we would like to accomplish. Column A (A-G) are the fields. Columns B-F are the options that can be entered for the given field. And the last row (Total Marks in Category) is multiplied by a given number depending upon what is entered as an option for the given field. Please let me know if there are any questions.

9 answers

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.
July 31, 2014

You might want to try something like:

Option val = issue.get("customfield_13603")
if (val == null)
  return null;
if (val.getValue().equalsIgnoreCase("0 (default)"))
  return 0;
if (val.getValue().equalsIgnoreCase("1 - 5"))
  return 1;
...

TCampbell August 10, 2014

Thanks David for getting back to me. I have entered in what you have suggested and nothing is being populated into the field. I am not sure what is wrong because there are no error messages or anything.

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.
August 10, 2014
Did you look into your logs for errors? Try displaying the issue with the field and then immediately look at the log. It should tell you if you have a syntax error.
TCampbell August 10, 2014

Great, thanks. Can you let me know where exactly in the logs I should be looking?

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
August 10, 2014

Any time you try to actively use the field. Best thing to do is have a browser and a terminal open next to each other on your computer.

On the terminal, be tailing the log, so you're seeing it as Jira writes to it.

In the browser, edit an issue on-screen.

Any output the field throws into the log will be instantly echoed. (I've used the "edit" action as it's the most llikely to get the field's code to be called)

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.
July 30, 2014

If O understand correctly, you have created 7 custom fields on your issues, named "A" to "G". What is the field type of these fields?

Also, I don't understand your Excel spreadsheet. What do the "1"s in the cells mean? I would assume that your fields are of type "Select", and you have created possible values equal to "0 (default)", "1-5", etc. Right? And thus the user can select a value for each field?

0 votes
TCampbell July 30, 2014

As of now I am only worrying about Field A (Eventually we are going to create Fields B-G). So let's just say I have created 1 custom field for now. This field is a radio button field with 5 options: 0, 1-5, 6-10, 11-15, and 16-100). The 1's in the cells mean that the user is selecting one of these options. I understand the 1 can be confusing (I didn't create the spreadsheet), so I would just think of it is a checkbox.

0 votes
Matheus Fernandes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 30, 2014

Hey Campbell,

We just spoke on the phone. Regarding your questions about the Calculated Number Field custom field from the JIRA Misc Custom Fields, you can get further help from Innovalog's Support team please see this Getting Support page. :)

Cheers,
Matheus

Matheus Fernandes
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 30, 2014

I have just edited your question to add this add-on's tag so that the Innovalog team can see it.

0 votes
TCampbell July 24, 2014

Here is what I have so far for the calculated number field. Can someone please take a look and help me out with this?

<!-- @@Formula:

issue.get("customfield_13603") != null ?

if (value === 6)

return (value * 2);

if (value === 7)

return (value * 2);

if (value === 8)

return (value * 2);

if (value === 9)

return (value * 2);

if (value === 10)

return (value * 2);

-->

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.
July 22, 2014

You could also try Script Runner, there is an example of the principal of what you are trying to do here: https://jamieechlin.atlassian.net/wiki/display/GRV/Scripted%20Fields#ScriptedFields-Calculateanumberbasedonotherfields

0 votes
TCampbell July 22, 2014

I did some research and downloaded this add-on which allows you to use a "Calculated Number Field"

https://marketplace.atlassian.com/plugins/com.innovalog.jmcf.jira-misc-custom-fields

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 22, 2014

What are you planning to use to calculate this?

0 votes
TCampbell July 21, 2014

Here is a zommed in version of the original image I included.

Suggest an answer

Log in or Sign up to answer