Hello,
We are using scriptrunner to assign an user when the issue is created. But now everytime the user Robine is assigned to the issue. Can someone check this scriptrunner code?
It worked before so maybe there are some changed i need to make in de code.
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.event.type.EventDispatchOption;
def issueManager = ComponentAccessor.getIssueManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager();
def unitInCharge = customFieldManager.getCustomFieldObjectByName("Unit in Charge");
MutableIssue issue = (MutableIssue) event.issue
String unit = issue.getCustomFieldValue(unitInCharge).toString();
final String PLANT_MANAGER = "robine";
final String LOGISTICS = "theo";
final String PRODUCTION = "robine";
final String HSEQ = "dick";
final String MAINTENANCE = "hans";
final String PROCESS_ENGINEERING = "krijn";
final String PROJECT_ENGINEERING = "pieter";
final String LABORATORY = "martin";
final String HUMAN_RESOURCES = "robine";
final String OPERATIONS = "krijn";
final String FINANCE = "vincent";
switch(unit) {
case "Plant Manager":
issue.setAssigneeId(PLANT_MANAGER);
break;
case "Logistics":
issue.setAssigneeId(LOGISTICS);
break;
case "Production":
issue.setAssigneeId(PRODUCTION);
break;
case "HSEQ":
issue.setAssigneeId(HSEQ);
break;
case "Maintenance":
issue.setAssigneeId(MAINTENANCE);
break;
case "Process Engineering":
issue.setAssigneeId(PROCESS_ENGINEERING);
break;
case "Project Engineering":
issue.setAssigneeId(PROJECT_ENGINEERING);
break;
case "Laboratory":
issue.setAssigneeId(LABORATORY);
break;
case "Human Resources":
issue.setAssigneeId(HUMAN_RESOURCES);
break;
case "Operations":
issue.setAssigneeId(OPERATIONS);
break;
case "FINANCE":
issue.setAssigneeId(FINANCE);
break;
default:
break;
}
Thanks!
Hi @b.onderwater ,
Have you used some logs to display the unit value and make sure the correct case was triggered?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.