Forums

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

Updating an existing checkbox in Groovy

Sam Morris
Contributor
July 24, 2019

Hi

I was wondering if anyone could help, I'm currently trying to write a post function script that updates a checkbox field on a parent issue.  The script takes the environment value from a text field in the subtask called "Release Environment" and checks the equivalent  box on the parent tick checkbox field "App Deployed To Environment"

So far I've come up with this, which seems to run fine without any errors however the field doesn't get updated. Am I missing anything obvious?


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

def parent = issue.getParentObject() as MutableIssue


def customFieldManager = ComponentAccessor.getCustomFieldManager()
def optionsManager = ComponentAccessor.getOptionsManager()
def issueManager = ComponentAccessor.getIssueManager()

def releaseEnvironment = customFieldManager.getCustomFieldObjects(issue).find {it.name == 'Release Environment'}
def releaseEnvironmentVal = issue.getCustomFieldValue(releaseEnvironment)

def parentAppDeployedTo = customFieldManager.getCustomFieldObjects(parent).find {it.name == 'App Deployed To Environment'}
def parentAppDeployedToValue = parent.getCustomFieldValue(parentAppDeployedTo)

def fieldConfig = parentAppDeployedTo.getRelevantConfig(parent)

def options = optionsManager.getOptions(fieldConfig)

def optionsToSet = options.findAll { it.toString() == releaseEnvironmentVal }
parent.setCustomFieldValue(parentAppDeployedTo, [optionsToSet, parentAppDeployedToValue])

 

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events