I'm trying to pass the values from one checkbox to another, but it's not working
What am I doing wrong? (or missing)
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def Equipment_new = customFieldManager.getCustomFieldObject("customfield_15721")
def Equipment_new_value = issue.getCustomFieldValue(Equipment_new).toString()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def String myval2 = "${Equipment_new_value}"
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_15720") //Equipment_current
def cfConfig = cfSelect.getRelevantConfig(issue)
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find
{it.toString() == "${myval2}"}
issue.setCustomFieldValue(cfSelect, value)
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
will run in a post function.
Hello @Dante Labate again.
Change it.toString() to it.value
Hello @Mark Markov (again)
I already tested this change, but it also did not work.
The script does not show an error, but the field does not change.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I already tested with the option:
it.value in
(can have more than one option selected)
but not work..
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You code seems a little bit strange. Why you need this many declaration with gstrings for the one value?
Try this code, ive added logging, when you will be test it, look in logs and see what exactly happen when script work.
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def Equipment_new = customFieldManager.getCustomFieldObject("customfield_15721")
def Equipment_new_value = issue.getCustomFieldValue(Equipment_new).toString()
log.error("Equipment value: "+ Equipment_new_value)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cfSelect = ComponentAccessor.customFieldManager.getCustomFieldObject("customfield_15720") //Equipment_current
def cfConfig = cfSelect.getRelevantConfig(issue)
log.error("OPTIONS : "+ ComponentAccessor.optionsManager.getOptions(cfConfig))
def value = ComponentAccessor.optionsManager.getOptions(cfConfig)?.find
{it.toString() == Equipment_new_value}
log.error("FINDED OPTION VALUE: "+ value)
issue.setCustomFieldValue(cfSelect, value)
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.