Maybe its only due to Friday afternoon why I don't see the error, but why does the following code return false instead of true?
assert cfValues['MyMultiSelect']*.value.contains("Test")
| | | |
| [null:Test, 1:Test] | false
| [Test, Test]
This seems to work now. customfield_10119 and Test are the variables to be defined ;-)
Thanks Henning.
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.impl.CascadingSelectCFType
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
CustomField cf= customFieldManager.getCustomFieldObject("customfield_10109")
issue = componentManager.getIssueManager().getIssueObject(issue.id)
def value = issue.getCustomFieldValue(cf)
def parentValueA = value[CascadingSelectCFType.PARENT_KEY]
def childValueA = value[CascadingSelectCFType.CHILD_KEY]
if (parentValueA.value=='Test' || childValueA.value=='Test') {
return true
} else {
return false
}
And to make a long story short - this also seems to do the trick:
cfValues['MyCascadingSelect']*.value.value.contains("Test")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Did you check the class of the elements in cfValues['MyMultiSelect']*.value?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I might have been not precise enough in my original question. It is a Cascading Select custom field. Actually I was currently already looking at that:
assert cfValues['MyCascadingSelect'].class
| | |
| [null:Test, 1:Test] null
It returns "null" for the class. Some additional help would be very welcome.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What's the output for
assert cfValues['MyMultiSelect']*.value[0].class
?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
log.warn cfValues["MyCascadingSelect"]*.value[0].class returned: null
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Mmh.
I use
def value = issue.getCustomFieldValue(cfA) // which should be the same as cfValues['CS Field A']
def parentValueA = value[CascadingSelectCFType.PARENT_KEY]
if (parentValueA) {
def childValueA = value[CascadingSelectCFType.CHILD_KEY]
//...
}
to access the content of a cascading select field. Could you try this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Entering this in the script console
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.customfields.impl.CascadingSelectCFType
ComponentManager componentManager = ComponentManager.getInstance()
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()
CustomField cf= customFieldManager.getCustomFieldObject("customfield_10109")
issue = componentManager.getIssueManager().getIssueObject("xxxx-651")
log.warn cf.class
log.warn "-----------------------"
def value = issue.getCustomFieldValue(cf)
def parentValueA = value[CascadingSelectCFType.PARENT_KEY]
if (parentValueA) {
def childValueA = value[CascadingSelectCFType.CHILD_KEY]
//...
log.warn "Test parentValueA: " + parentValueA
log.warn "Test childValueA: " + childValueA
}
returns the expected results (test , test) and
class com.atlassian.jira.issue.fields.CustomFieldImpl
Does this help to build the condition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I think so :-) You could than check both values for "Test".
if (parentValueA=='Test' || childValueA=='Test') {
return true
} else {
return false
}
You could enter the whole code as a condition, your are not restricted to one row.
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.