Cannot find matching method Script127#getFieldById(java.lang.String). Please check if the dec...

Madhusudhan October 29, 2020

While running the below script, getting an above like error at line 10,  12 and 23. Does any one faced the same - Please suggest

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

import static com.atlassian.jira.issue.IssueFieldConstants.ISSUE_TYPE

def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def allIssueTypes = ComponentAccessor.constantsManager.allIssueTypeObjects

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueTypeField = getFieldById(ISSUE_TYPE)

def remoteUsersRoles = projectRoleManager.getProjectRoles(user, issueContext.projectObject)*.name
def availableIssueTypes = []

if ("Users" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Query", "General Request"] })
}

if ("Developers" in remoteUsersRoles) {
availableIssueTypes.addAll(allIssueTypes.findAll { it.name in ["Bug", "Task", "New Feature"] })
}

issueTypeField.setFieldOptions(availableIssueTypes)

1 answer

1 accepted

1 vote
Answer accepted
Fazila Ashraf
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 29, 2020

Hi @Madhusudhan 

Welcome to the community!

The given behaviour code works for me.

Can you confirm that you are adding this in the behaviour section?

Madhusudhan December 16, 2020

Hi @Fazila Ashraf , I was adding this code at different place. Now  I have added the code in the behavior section and that worked. Thank you :)

Suggest an answer

Log in or Sign up to answer