Forums

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

To set assignee when issue is moved

Eshwar Palem
Contributor
March 21, 2019
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.event.type.EventDispatchOption;

Issue issue = event.getIssue();
MutableIssue mutableIssue = null;
mutableIssue = issue;
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();

if(issue.getIssueType().getName().equalsIgnoreCase("Legal"))
{
mutableIssue.setAssignee(user);
ComponentAccessor.getIssueManager().updateIssue(user, mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false);
}

 The above one is my script to set the assignee when an issue is moved from one issuetype to another issuetype,the assignee should be of issuetype to which an issue is moved.

I am getting an error like "cannot an assign value of type com.atlassian.jira.issue.Issue to variable of type to com.atlassian.jira.issue.MutableIssue"

1 answer

1 accepted

0 votes
Answer accepted
Tom Lister
Community Champion
March 21, 2019

Try

mutableIssue = ComponentAccessor.getIssueManager().getIssueByCurrentKey(issue.getKey);
Eshwar Palem
Contributor
March 21, 2019

Hi, @Tom Lister 

Now my script is with zero errors after adding the above line, thanks for that. but when I am adding this to Script listeners in Scriptrunner it is not running yet after doing the move operation. Do you have any suggestions for this like what will be the solution.

Thanks in advance.

Tom Lister
Community Champion
March 21, 2019

Hi

Hard to say without running it. Are there any errors in the Jira log?

can you put some logging statements in your code. 

Even if it’s compiling it may be having an error retrieving the issue. Possibly getting a nullpointerexception

Eshwar Palem
Contributor
March 22, 2019

Hi Tom,

I am getting this error:

groovy.lang.MissingPropertyException: No such property: event for class: Script299 at Script299.run(Script299.groovy:18).

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events