Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Issue type restriction specified to roles

mahavishnu May 16, 2019

Issue type : Bug and Defect , should access to create form only to reader roles . 

 

Any one can help on this groovy  scripting  : If this is the solution ,Providing  scripts will help me on this part .

I have refereed script runner documentation as well . As im fresher to this topic its hard for me to implement on emergency    . And also please provide on any help line mail for script runner scripts to reach adaptavist  on getting help from scripts ?

Or 

Any default jira settings to implement this ?   or Plugin other that groovy scripts ?

 

Thanks for help !

2 answers

1 vote
Andrew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 16, 2019

Hi @mahavishnu ,

As workaround You can create separate workflow for types (Bug and Defect). And then add 'validator' of the permission to create transition in new workflow.

B.R.

Tarun Sapra
Community Champion
May 16, 2019

Yes, this is a good option as well, and role based validation is also supported by the built-in scripts (simple scripted validator) of the script runner

mahavishnu May 28, 2019

Hello 

i have tried with this script 

import com.atlassian.jira.bc.projectroles.ProjectRoleService;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.security.roles.ProjectRoleActors;
import com.atlassian.jira.security.roles.ProjectRoleManager;
import com.atlassian.jira.security.roles.RoleActor;
def project = issue.getProjectObject();
log.debug( project.getLeadUserKey());
String role="Reader"
ProjectManager projectManager = ComponentAccessor.getProjectManager();
ProjectRoleService projectRoleService = (ProjectRoleService) ComponentAccessor.getComponentOfType(ProjectRoleService.class);
ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
final Collection<ProjectRole> projectRoles = projectRoleManager.getProjectRoles();
def roles=projectRoleManager.getProjectRoles(currentUser, project);
log.debug(""+roles)

for (ProjectRole pr : roles) {
if ((pr.getName().toUpperCase().equals(role.toUpperCase())) && issue.issueType.name == "Bug") {
return false;
}

}
return true

 

Still other roles can able to create .

 

Thanks in advance . Help required 

Andrew
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 28, 2019

Hi @mahavishnu ,

I suppose code return true in any case. Also are You sure that should return false, maybe need inverse?

Try next:

def result = false // sure that should return false, maybe need inverse?

if (issue.issueType.name == "Bug"){

    if (roles.find{ it.getName().toUpperCase().equals(role.toUpperCase()) } ){

         result = true

      }

}

return result

B.R.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events