script creating issue get "You don't have permission to assign issues"

attlaa December 5, 2019

Hello,

I'm using script runner in post function to create new issue and link it with current working issue. It's strange that I didn't set the assignee in the workflow(new issue creating) but I still get the error "You don't have permission to assign issues". Could you please help with this strange case? Thanks.

 

BR

Xavi

1 answer

1 accepted

0 votes
Answer accepted
Elifcan Cakmak
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.
December 6, 2019

Hello,

Could it be because there is a screen on create transition of the new issue you are trying to create? There may be required fields on these screen like assignee. 

Or there may be a post function that sets the assignee on this create transition. I suggest you check the workflow of the new issue you are trying to create.

Regards,

Elifcan

attlaa December 8, 2019

Thanks Elif. Yes, I've checked the workflow of the new created issue, but the assignee field is not required on the create screen. And for the workflow, I didn't add any post function to set the assignee...Now the workaround is to grant "reporter"  the "assignee issue" permission but this caused some reporters assign the issue to himself during the workflow. Could you please suggest? Thanks again.

BR

Xavi

Elifcan Cakmak
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.
December 9, 2019

Is there a default assignee on the project itself? You can check it on project's settings > Users and Roles. 

Could there be default assignees based on components? You can check it on project's settings > Components.

Could there be a property on the workflow statuses such as jira.permissions.assign.denied ?

This error suggests that somehow there is a rule that when creating a new issue, assignee should be assigned.

Also how exactly are you trying to accomplish this? With a customized script or a built in feature of Script Runner plugin? 

attlaa December 9, 2019

Hello Elifcan,

Thanks for your reply. I've checked all  you mentioned in your answer, no default assignee, no component and no property was set in the workflow. I can create the issue on webUI. The error only occurred when using script runner(post function script) to create issue. The script is as below.

issueInputParameters

.setProjectId(targetProject.getId())
.setSummary(issue.getSummary())
.setDescription(issue.getDescription())
.setIssueTypeId(issueType.getId())
.setPriorityId(issue.priorityId)
.setReporterId(issue.reporterId)
.setSkipScreenCheck(true)

IssueService.CreateValidationResult createValidationResult =issueService.validateCreate(user, issueInputParameters)

if(!createValidationResult.isValid()){

   log.error(createValidationResult.getErrorCollection())
}

Elifcan Cakmak
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.
December 9, 2019

This script seems like missing some important parts. Did you copy the whole script? Because there should be an else like this:

else {
issueService.create(user, createValidationResult)
}

Also which user do you use as "user", the logged in user or a static single user or anybody else? 

attlaa December 9, 2019

No, I didn't copy the whole script. I used the below script

if(!createValidationResult.isValid()){

   log.error(createValidationResult.getErrorCollection())
}

else{

  IssueService.IssueResult createResult = issueService.create(user,createValidationResult)
   if(!createResult.isValid()){
     log.error("Error while creating the issue.")
   }

}

and user is used as the logged in user.

ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()

Elifcan Cakmak
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.
December 9, 2019

I found a bug report which seems related to your issue? Can you check this out?

https://jira.atlassian.com/browse/JRASERVER-42609

What Jira version are you using? This may be your problem.

Because I couldn't think of any other reason but a bug at this point.

attlaa December 10, 2019

Thanks. I'm using version 7.8.0

Suggest an answer

Log in or Sign up to answer