Hi all,
I'm trying to create a behavior where I set values within a specific field based on which project is active within the "Create" screen.
How would I do this?
Currently, I've tried the following code: (I get a "null" value for the project name)
def projectField = getFieldById("project-field")
def projectFieldValue = projectField.getValue()
log.warn("value: $projectField")
def teamAffiliationField = getFieldById("customfield_11401")
//Defines which team affiliation values we want available when code below runs.
def teamAffiliationOptions = [
"Project #1": ["option 1","option 2", "option 3"],
]
//Defines if grouping of team affiliation values activates depending on which project is currently selected.
if (teamAffiliationOptions[projectFieldValue]){
teamAffiliationField.setFieldOptions(teamAffiliationOptions[projectFieldValue])
}
If anyone can let me I'd greatly appreciate it.
Thanks,
Mike
I've figured it out on my own.
Since I'm in the creation screen, I needed to use issuecontext.
Here is an example of the code used to pull in the project name:
//Pulls in project details
def projectDetails = getIssueContext().getProjectObject()
//Grabs the project name from the project details previously pulled in.
def projectName = projectDetails?.getName()
//Shows a log for what the value of the about project name is.
log.warn("value: $projectName")
def teamAffiliationField = getFieldById("customfield_11401")
//Defines which team affiliation values we want available when code below runs.
def teamAffiliationOptions = [
"Project #1": ["option 1","option 2","option 3"],
]
//Defines if grouping of team affiliation values activates depending on which project is currently selected.
if (teamAffiliationOptions[projectName]){
teamAffiliationField.setFieldOptions(teamAffiliationOptions[projectName])
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.