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

how to set a multiselect list to its default option while creating a new issue using Groovy

I have a post function script which creates a new issue(of different issue type), in the new issue I have to set the value of a multi select custom field to its default value (during the new issue creation). 

2 answers

Suggest an answer

Log in or Sign up to answer
2 votes
Thanos Batagiannis [Adaptavist]
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.
Nov 10, 2017

Hey Praveen,

So in order to get the default configured value for a custom field the way to do will be something like 

def cf = ComponentAccessor.customFieldManager.getCustomFieldObjectByName("CustomFieldName")


def givenIssueContext = new IssueContextImpl(issue.projectObject, issue.issueType)
def globalContext = IssueContext.GLOBAL

// depends on your cf configuration use the globalContext or the givenIssueContext
def fieldConfig = ComponentAccessor.fieldConfigSchemeManager.getRelevantConfig(IssueContext.GLOBAL, cf)
def defaultValue = cf.getCustomFieldType().getDefaultValue(fieldConfig)

Hope that helps, ping me if you have any more questions.

Regards, Thanos

0 votes
Alexey Matveev
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.
Nov 10, 2017

Hello,

I think it is simpler to set a default value for the field in a standard Jira configuration. You can read here more about it

https://confluence.atlassian.com/adminjiraserver071/configuring-a-custom-field-802592532.html

Hi Alexey, we have already set the default value as the required one. But the real problem is we are creating the new issue using GROOVY, that doesnt set the field value to the default one and it remains empty.

Alexey Matveev
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.
Nov 10, 2017

What is your creation script?

TAGS
AUG Leaders

Atlassian Community Events