Wants to hide Custom Field Dropdown Values for three different Jira groups.
JIRA Group name:
Quality Team
PO Leads
Scrum Master
Drop down field name: Bug type:
Dropdown values:
QA Bug
UAT and PO bug
SNOW-Prod Bug
Conditions:-
1. QA Bug value will show only for Quality team
2. UAT Bug, PO Bug, SNOW-Prod Bug will show only for PO Leads group
3. SNOW-Prod Bug will show only for Scrum Master group
We have already tried with below script in the Behavior.. But it's not working for the scenario. Please help us with the correct script.
import com.onresolve.jira.groovy.user.FieldBehaviours
We go the script this scenario.
import com.atlassian.jira.component.ComponentAccessor // Get relevant components def customFieldManager = ComponentAccessor.getCustomFieldManager() def optionsManager = ComponentAccessor.getOptionsManager() def groupManager = ComponentAccessor.getGroupManager() // Get select list field and its options def selectList = getFieldById("customfield_13235") // Replace with actual field ID def customField = customFieldManager.getCustomFieldObject(selectList.getFieldId()) def config = customField.getRelevantConfig(getIssueContext()) def options = optionsManager.getOptions(config) // Example: Determine user's group dynamically def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser() def userGroups = groupManager.getGroupsForUser(currentUser).collect { it.name } // Define groupOptionsMap with actual options def groupOptionsMap = [ "TCx Scrum Master": ["SNOW-Prod Bug"], "TCX QA": ["QA Bug"], "TCX PO Leads": ["UAT Bug", "PO Bug", "SNOW-Prod Bug"] ] // Initialize selectedOptions variable def selectedOptions = null // Iterate through groupOptionsMap to find matching user group groupOptionsMap.each { groupName, validOptions -> if (userGroups.contains(groupName)) { selectedOptions = options.findAll { it.value in validOptions }.collectEntries { [(it.optionId.toString()): it.value.toString()] } as Map<String, String> println("User belongs to ${groupName} group. Valid options: ${validOptions}") return // Exit loop once group is found } } // Set the field options based on the user's group if (selectedOptions) { selectList.setFieldOptions(selectedOptions) } else { // If user doesn't belong to any group, handle as needed (e.g., set default options) selectList.setFieldOptions([:]) }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.