Forums

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

Behavious :How to get user information of custom fields in scripts?

木尧青 October 15, 2021

Hi,

I don't know how to restrict the required options of another custom field according to the user group information of the user of the custom field.

To be honest, I'm not familiar with this script because my colleague left.

import com.onresolve.jira.groovy.user.FieldBehaviours
import com.onresolve.jira.groovy.user.FormField
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()

def LinkedProjectField=getFieldByName("LinkedProject")
def DirectorField = getFieldByName("Director")

String groupName = "Japan usergroup"

if (ComponentAccessor.groupManager.getUsersInGroup("Japan usergroup").contains(DirectorField)) {
LinkedProjectField.setRequired(true)
}else{
LinkedProjectField.setRequired(false)
}

This is the script I wrote. I hope it will take effect when creating issues, but it didn't succeed.

Is there a solution, workaround for that?

Thank you in advance

Evelyn

 

0 answers

Suggest an answer

Log in or Sign up to answer