I need to send an email to a group (I believe a Jira group) if one of 4 user picker fields is empty.
The only plugin I seem to have available at my disposal to do this is ScriptRunner, and it requires syntax which I am woefully unfamiliar with.
Before sending me hatemail about an answer being out there, please know that I tried looking and I saw various examples showing various ways of dealing with a single user picker field, but not how to create a condition in which any of multiple fields is empty. (null)
This should return true is any of the fields is null. Just adjust the fieldNames
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def fieldNames = ['multiUserFiel1','multiUserField2']
fieldNames.any{fieldName->
def customField = customFieldManager.getCustomFieldObjects(issue).find{fieldName}
customfield && issue.getCustomFieldValue(customField) == null
}
Thanks! I am assuming this will work with any field, single or multi user picker, or any other field. Is that right?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Presumably yes.
I'm not sure if there are any types of field that would ever have a non-null representation of an empty value.
It's possible that a free text field that was populated in the past, when cleared would return an emtpy string rather than a null.
So we can instead use the following (also corrected an error I made in the first instance):
import com.atlassian.jira.component.ComponentAccessor
def customFieldManager = ComponentAccessor.customFieldManager
def fieldNames = ['multiUserFiel1','multiUserField2']
fieldNames.any{fieldName->
def customField = customFieldManager.getCustomFieldObjects(issue).find{it.name == fieldName}
fieldName && !issue.getCustomFieldValue(customField)
}
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.