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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,466,048
Community Members
 
Community Events
176
Community Groups

Field value calculation based on another field

Hi Team,

We have 5 single select field(Strategic Importance,Customer Impact,Stakeholder Buy-In,Time to Implement,Resource Requirement) which are having numeri values in all the fields and when we select any one of those values from the 5 fields in the 6th text field(Total Project Rating) value should populate based on the below query. Can some one help me on this.

formula - 

Total Project Rating = (Strategic Importance * 0.25) + (Customer Impact * 0.25) + (Stakeholder Buy-In * 0.25) + (Time to Implement * 0.15) + (Resource Requirement * 0.10) 

2 answers

1 accepted

1 vote
Answer accepted

Using the scriptrunner script editor, create a file with a name like "totalProjectRatingCalculationBehaviour.groovy"

Add the following to the file:

import com.atlassian.jira.issue.customfields.option.Option
import com.onresolve.jira.groovy.user.FieldBehaviours
import groovy.transform.BaseScript

@BaseScript FieldBehaviours fieldBehaviours

def strategicImportanceFld = getFieldByName('Strategic Importance')
def customerImpactFld = getFieldByName('Customer Impact')
def stakeholderBuyInFld = getFieldByName('Stakeholder Buy-In')
def timeToImplementFld = getFieldByName('Time to Implement')
def resourceRequirementFld = getFieldByName('Resource Requirement')
def totalProjectRatingFld = getFieldByName('Total Project Rating')

def strategicImportanceValue = (strategicImportanceFld.value as Option).value as Integer
def customerImpactValue = (customerImpactFld.value as Option).value as Integer
def stakeholderBuyInValue = (stakeholderBuyInFld.value as Option).value as Integer
def timeToImplementValue = (timeToImplementFld.value as Option).value as Integer
def resourceRequirementValue = (resourceRequirementFld.value as Option).value as Integer

def totalProjectRatingValue = strategicImportanceValue * 0.25 +
customerImpactValue * 0.25 +
stakeholderBuyInValue * 0.25 +
timeToImplementValue * 0.15 +
resourceRequirementValue * 0.1

totalProjectRatingFld.setReadOnly(true).setFormValue(totalProjectRatingValue)

From scriptrunner behaviour, create a new behaviour configuration that maps to the correct projects/issue type.

Add each of your 5 source fields to the behaviour configuration. For each field, add a server-side script and then change the script from in-line to file. Point to the file you created above.

Save the behaviour.

Now, each time you modify any of your five fields, the Total Project Rating field will automatically update with a fresh calculation.

Hi @Peter-Dave Sheehan , the script is not working. I tried it in listeners and behavior also but still not working.

This is a behaviour script. I can only work in a behaviour configuration like I described.

Can you please include screenshots of your behaviour configuration?

Also can you verify that the field names in the script are spelled 100% correctly?

Are you finding any errors in the <jira-home>/log/atlassian-jira.log when you try to create issues?

Hi @Marta Woźniak-Semeniuk those are not related to my requirement.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events