How to use ScriptRunner in order to calculate a value for a custom field ('Score')?

Steven Huxstep December 16, 2020

My team is interested in creating a custom field that uses the values of 2 other fields to display an overall 'Score'.

The first field would be 'Story Points', which just displays the story points and is located on the issue card. The second would be 'Value' which would be a text drop down list of options ranging from 'Priority High ----> Priority Low'. My question is can each of the selection options (i.e. Priority High) be given an inherent numerical value or weighting? Because the third field we would like to call 'Score' which is to display the answer of our 'Value' field (depending on what drop down selection option was chosen since each would have a different numerical weighting) DIVIDED by Story points.

Is this possible?

1 answer

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.
December 16, 2020

>can each of the selection options (i.e. Priority High) be given an inherent numerical value or weighting?

The field options themselves, no, there's no code or database structure to handle adhoc option properties in Jira.  There are some properties options have, but they're hard-coded.

Most of us trying to do things like this simply hard-code it into the script.  The pseudo-code of the script is along the lines of

get story-points
get value
v = 1
if value == high then v = 3
if value == medium then v = 2

return ( v / storypoints )

 

You could try to implement properties on options, but that would probably need a full blown app.

For some help with the code, there's a good sample of working with different types of fields and their content over at https://library.adaptavist.com/entity/update-the-value-of-custom-fields-through-the-script-console  (It is a console script, but the code is good for scripted fields too)

Steven Huxstep December 16, 2020

>The field options themselves, no, there's no code or database structure to handle adhoc option properties in Jira.  There are some properties options have, but they're hard-coded.

Thought as much, thank you for clarifying.

Would that pseudo-code be applicable to the custom scripted field more so than the script console? The link provided returns a 404 error.

Thank you for your reply.

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.
December 16, 2020

Damn Khoros bug - it pads urls with control characters and messes up links.  I'll fix that in a second.

Yes, the pseudo code is for a scripted field - scripted fields expect their scripts to return the value for them to store and display, hence the "return" at the end of it.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.7.1
TAGS
AUG Leaders

Atlassian Community Events