Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How can I set a Scriptrunner condition on any of multiple user picker fields being empty?

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)

1 answer

1 accepted

2 votes
Answer accepted

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?

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)
}
Like Rob Horan likes this

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you