Hello Community, I've encountered this problem where I can't hide other priorities based on the behaviour. I already associated the project to a new priority scheme but still no luck on getting the Added Priority I've made. I'm using scriptrunner code from their example.
I added Priority 1 - 4, and used this code
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.sal.api.user.UserManager
import static com.atlassian.jira.issue.IssueFieldConstants.PRIORITY
def constantsManager = ComponentAccessor.getConstantsManager()
def userUtil = ComponentAccessor.getUserUtil()
log.debug ComponentAccessor.getComponent(UserManager)
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
if (userUtil.getGroupNamesForUser(currentUser.name).contains("Change Request Approval Team")) {
def allowedPriorities = constantsManager.getPriorities().findAll() {
it.id.toInteger() in [8,9,10,11]
}.collectEntries {
[(it.id): it.name]
}
getFieldById(PRIORITY).setFieldOptions(allowedPriorities)
} else if (!userUtil.getGroupNamesForUser(currentUser.name).contains("Change Request Approval Team")) {
def allowedPriorities = constantsManager.getPriorities().findAll() {
it.id.toInteger() in [10,11]
}.collectEntries {
[(it.id): it.name]
}
getFieldById(PRIORITY).setFieldOptions(allowedPriorities)
}
I used --> it.id.toInteger() in [8,9,10,11] to get the ID based on the position of Priority, but it can't capture the Added Priorities BUT whenever I used --> it.id.toInteger() in [1,2,3,4], it captures the Top 4 Priorities. Can someone help me out here? Thanks!