Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Need a condition for custom field

Alfred Carlomagno May 17, 2018

I'm trying to set up a condition or validation for a transition where a custom field (User Picker (single user)) user is in a group and not a particular user.  I'm not really familiar with scripting so don't understand the syntax too well.

 CustomFieldValue("customfield_11407") = UsersInGroup("Prod-Support") AND not username=prod-support

 

 

3 answers

0 votes
Alfred Carlomagno May 17, 2018

I would need to set this up without a plugin, I'm not clear on how to apply at least the first condition.image.png

 

CustomFieldValue("customfield_11407") = UsersInGroup("Prod-Support") 

0 votes
Tuncay Senturk _Snapbytes_
Community Champion
May 17, 2018

Hello,

 

Below code checks whether the user in customfield belongs to group ("prod-support")

import com.atlassian.jira.component.ComponentAccessor

def groupManager = ComponentAccessor.getGroupManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupSupport = groupManager.getGroup("Prod-Support")
def customField = customFieldManager.getCustomFieldObject("customfield_11407")
def cfval = issue.getCustomFieldValue(customField)

groupManager
.getUserNamesInGroup(groupSupport).contains(cfval)

 

Keep in mind that I did not test the code ;)

Alfred Carlomagno May 18, 2018

Looks promising, I'll have to test.

 

Thanks, 

Alfred Carlomagno May 22, 2018

This is what I tried, however, doesn't seem to work as expected. Note I did use a different group created just for this condition. Am I doing something wrong?

 

image.png

0 votes
Matt Doar
Community Champion
May 17, 2018

You can define conditions in two parts then AND them together. But I'm not sure that standard Jira provides a NOT operator when defining conditions. There may be a plugin that does this, certainly the ScriptRunner custom conditions and validators do

Suggest an answer

Log in or Sign up to answer