Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

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

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

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

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

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

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