Forums

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

How to skip assigning to the default assignee though the script when user selects assignee in create

Aravindi Amarasinghe
Contributor
September 17, 2018

Hi All, 

I have this script assigning issues to particular users based on specific words in the summary and default to project lead. But when user selects the assignee in the create screen it still default to the project lead. 

Can some one suggest changes to this script to skip assigning to project lead when user select one in the create screen? 

import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.*;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;


MutableIssue myIssue = issue;
String summary = issue.getSummary();
String userName;
def userManager = ComponentAccessor.userManager;

log.error("Summary choosen: " + summary)


//Capture string in the summary to assign to helpdesks
if (myIssue.summary.toString().matches(".*AAA")){
userName = "e1111111"
}


else if (myIssue.summary.toString().matches("(.*)#BBB#(.*)")) {
userName = "e2222222"
}


else {
userName = issue.getProjectObject().getProjectLead().getKey()
}


log.error("Username chosen: " + userName)

//Assigning the issue to the value picked by userName

def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
issue.setAssignee(ComponentAccessor.getUserManager().getUser(userName))
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)

1 answer

0 votes
Aravindi Amarasinghe
Contributor
September 17, 2018

aaaaaa.JPG

The script in 3rd post function I changed 4th one to 3rd  and tried. so that it assign to the selected assignee and assign back to project lead at the same time. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events