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).
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.
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
Project managers know this problem: A “mountain of work” lays in front of you, and you don’t know how and where to tackle them. Different to-dos lie ahead, but just one task after the other can be ha...
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