Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Edit Team Field in Post Function Script

Deleted user October 30, 2024

Hi Admins,

 

I need to edit Team advanced roadmap (plan) field on issues. But I can't get any options of it.

Does anyone know how to get team options and edit team field on postfunction?

 

Bests,

Deniz

 

import com.atlassian.jira.component.ComponentAccessor 
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.customfields.manager.OptionsManager
import com.atlassian.jira.issue.context.IssueContextImpl
import com.atlassian.jira.issue.context.IssueContext

// Retrieve the current issue
def issue = issue as MutableIssue
// Define the custom field ID for the Team field
def teamFieldId = "customfield_12345"
// Access the custom field manager
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def teamField = customFieldManager.getCustomFieldObject(teamFieldId)

if (!teamField) {
log.error("Team custom field not found.")
return
}

// Use the issue's context to retrieve field configuration
def optionsManager = ComponentAccessor.getComponent(OptionsManager)
IssueContext issueContext = new IssueContextImpl(issue.getProjectObject(),
issue.getIssueTypeObject())
def fieldConfig = teamField.getRelevantConfig(issueContext)
// Retrieve and log all options in the Team field
def allOptions = optionsManager.getOptions(fieldConfig)

if (allOptions) {
log.debug("Available options in Team field:")
allOptions.each { option ->
log.debug("Option value: '${option.value}' (ID: ${option.optionId})") }
} else {
log.error("No options found for the Team field in the current issue context.") }

 

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events