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

Is there any plugin or any feature in JIRA wherein we have 2 fields and the plugin allows us to choose a field among the two. So out of the 2 mandatory fields one of the field needs to be selected

Jayashree Shetty Sep 01, 2013

We have a scenario where in we have to include users and groups. But i am not sure if there is any field which allows to include user picker as well as group picker into a single field. So what we have done is that we have 2 separate fields - one for user picker and another for group picker. But among the two we need to select only one. But we need to pick one field since out of the two selecting one is mandatory

3 answers

1 accepted

0 votes
Answer accepted
Rambanam Prasad Sep 02, 2013

i suggest write your own validator using java or using script runner plugin

Jayashree Shetty Sep 19, 2013

I did try to create such validator bu looking into scripts from jamie. I am stuck in between. I have posted the code below

import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue

def issue = ComponentAccessor.getIssueManager().getIssueObject("TESTING-3")
CustomField group = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_12510")

CustomField ppl = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10141")

def pplVal = issue.getCustomFieldValue(ppl)
def groupVal = issue.getCustomFieldValue(group)


I have to compare these fields if they are null like

if(pplVal=="" or groupVal=="")


// Throw some exception that atleast one should be filled



But i am not getting the proper syntax for the above code. if i directly compare them then i get no return value and if i add pplVal.value == "" then i get "Cannot get property 'value' on null object". Can someone please help me in completing code.

Note pplVal is a user picker and groupVal is group picker

Rambanam Prasad Sep 19, 2013

i think you can use simple script something like this

if(cfValues['customfield_12510'] && cfValues['customfield_10141']){

//throw exception here


check this

Rambanam Prasad Sep 19, 2013

ine more thing from your code,

you have to put condition something like this

if(pplVal==null && groupVal==null)

because if the both field not selected then you need to through error correct?

Jayashree Shetty Sep 19, 2013

Hi Prasad, i dont know where i am going wrong. But still this code isnt working.

I have written it as

Even when the field has value or not this get fired and i 
cant proceed. Its a group picker field, does syntax changes ?
Secondly how will you write or condition for the above. I want 
atleast one of it to be checked. 
Please help
JamieA Sep 19, 2013
cfValues['Name of field']
is sufficient for the simple scripted validator. Note that null does not equal an empty string
Jayashree Shetty Sep 22, 2013

Hi Jamie, i did try , but it gets fired everytime.

0 votes
Mladen B Sep 02, 2013

This can be easily resolved creating a new Custom Field Type. There you can design the html of your new custom field and the logic behind it (java code). That way you will have the freedom to design your custom field exactly the way you want it to be.

0 votes
Jayashree Shetty Sep 22, 2013

Hi Jamie, does this script work even for multi user picker or multi group picker field? I have a state in workflow "Submit". There i have added the script cfValues['customfield_12512']. This gets fired when we have not chosen any user in the user picker field which is correct. But even when we pick some users we see the same error reappearing. I was assuming that this error will disappear. Am i missing something?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Marketplace Apps & Integrations

Join our webinar: “Asset Management: The Role of Context in ITSM” with Atlassian & Riada

  Hi Atlassian Community! This is Teresa from the Jira Service Desk team. On June 19th, I’ll be hosting a webinar “Asset Management: The Role of Context in ITSM” with Atlassian Partne...

178 views 2 3
Read article

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