Jira scriptrunner assign user when issue is created

b.onderwater
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 5, 2020

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! 

1 answer

0 votes
Antoine Berry
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 10, 2020

Hi @b.onderwater ,

Have you used some logs to display the unit value and make sure the correct case was triggered? 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events