We have request like we need to pop the users from specific user group in "User Picker (Single User)" field based on the another drop down fields option. So I have tried it with below script but getting "Unsupported type class java.util.LinkedHashMap in setFieldOptions()" error while executing it.
import com.atlassian.jira.component.ComponentAccessor
def userUtil = ComponentAccessor.getUserUtil()
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def userManager = ComponentAccessor.getUserManager()
def groupManager = ComponentAccessor.getGroupManager()
// def field = getFieldById("customfield_36450")
// Get the form fields
def regardingField = getFieldById("customfield_27500") // The field to check
def userPickerField = getFieldById("customfield_35100") // The user picker field
// Get the value of the regarding field
def regardingValue = regardingField.getValue()
// Check the value and restrict the user picker field based on the group
if (regardingValue == "AUTO AD") {
def group = groupManager.getGroup("MU Tech_Auto AD")
def groupMembers = groupManager.getUsersInGroup(group)
def userOptions = groupMembers.collect { [id: it.key, name: it.displayName] }
userPickerField.setFieldOptions(userOptions)
} else {
userPickerField.setFieldOptions([]) // Or some default options
}
We are using Jira Data Center Version 8.20.30
Please check and support me while resolving this error.
Thank You!
Best Regards,
Richa Aware
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.