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,461,858
Community Members
 
Community Events
176
Community Groups

Update Story Points field based on select list

Hi Team, 

We have a single select field ( T-Shirt Size) and based on the size selected 'Story point' Field must be updated automatically. 

if it S then it should be 1, M is 2 and L is 3 and so on. Can this be done using Script Runner. 

Please do let us know.

2 answers

1 accepted

0 votes
Answer accepted
Antoine Berry Community Leader Nov 07, 2019

Hi @M Vijay Kumar ,

I would suggest to use behaviours, it would make things visual for your users. Make story points read only, and use this script for the select list (update the ids) : 

import com.atlassian.jira.component.ComponentAccessor

int
selectListId = 12503
def selectList = getFieldById("customfield_" + selectListId)
def selectListValue = selectList.getValue()

int storyPointsId = 10002
def storyPoints = getFieldById("customfield_" + storyPointsId)

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def storyPointsValue

switch(selectListValue){
case "S": storyPointsValue = 1; break;
case "M": storyPointsValue = 2; break;
case "L": storyPointsValue = 3; break;
default: storyPointsValue = underlyingIssue?.getCustomFieldValue(customFieldManager.getCustomFieldObject(storyPointsId))
}

storyPoints.setFormValue(storyPointsValue)

Antoine

Thanks Antoine, It worked perfectly. 

Like Antoine Berry likes this
0 votes
Leo Community Leader Nov 07, 2019

Hi @M Vijay Kumar ,

Yes you can

1. If you want only during creation you can go with script runner post-function 

2. if you want even during Edit action as well you can consider scriptrunner listener for "Issue created and Issue Updated" events.

below snippet may help you, BTW I haven't tested you may need to correct something 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.ModifiedValue

def changeHolder = new DefaultIssueChangeHolder();
def tShirt = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("T-Shirt Size")
def story = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("Story Point")
def myIssue = event.issue

String size = myIssue.getCustomFieldValue(tShirt) as String
def point = null
if(size){
if(size == "S"){
point = 1
}else if(size == "M"){
point = 2
}else{
point = 3
}
}
if(point){
story.updateValue(null, myIssue, new ModifiedValue(myIssue.getCustomFieldValue(story),point), changeHolder)
}

 

BR,

Leo

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events