Hi,
Wondering if someone knows what is wrong with the script below to restrict issue types based on groups.
I get the following error:
[Static type checking] - Cannot find matching method script16947277872381970688303#If(boolean, groovy.lang.Closure <java.lang.Boolean>). Please check if the declared type is correct and if the method exists.
Possible solutions: find(), any(), is(java.lang.Object), wait(), use(java.lang.Class, groovy.lang.Closure), dump()
=================================================
import com.onresolve.jira.groovy.user.FieldBehaviours
import com.atlassian.jira.component.ComponentAccessor
import groovy.transform.BaseScript
import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE
@BaseScript FieldBehaviours fieldBehaviours
def groupManager = ComponentAccessor.groupManager
def allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects
def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueTypeField = getFieldById(ISSUE_TYPE)
def remoteUserGroups = groupManager.getGroupsForUser(user)*.name
def availableIssueTypes = []
If ('Admins' in remoteUserGroups)
{
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Admin Only Issue"] })
}
If ('Developers' in remoteUserGroups)
{
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Developer Only Issue"] })
}
issueTypeField.setFieldOptions(availableIssueTypes)
====================================================
Thank you.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.