Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Auto assign based on CF value

This have been discussed multiple time and I reviewed many answers but could not make my script to work....

I'm using this in the "behavior" to Assign to a specific user per the team the reporter selected on "issue created".

I'm getting the attached error below.

any help is much appreciated.

 

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.ExecutingHttpRequest
import com.atlassian.jira.issue.UpdateIssueRequest;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserUtil
import com.onresolve.jira.groovy.user.FormField

//point to the CF navigator Team and get the value
FormField team = getFieldById("customfield_14400")
def team_val = team.getValue().toString()

def issueManager = ComponentAccessor.getIssueManager()
def mIssue =

switch (team_val){
case "Data Center Ops":
mIssue.setAssignee("x")

break;

case "Data Traffic Engineering & Operations":
mIssue.setAssignee("y")

break;

case "Site Reliability Engineering & Storage Engineering":
mIssue.setAssignee("z")

break;

case "Sys Ops":
mIssue.setAssignee("a")

break;

case "Site Reliability Tools":
mIssue.setAssignee("b")

break;

}

 Screen Shot 2018-10-09 at 5.31.23 PM.png

1 answer

1 accepted

0 votes
Answer accepted

I was able to fix it myself (Yay)

instead of behavior I used post function script (my own script):

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.web.ExecutingHttpRequest
import com.atlassian.jira.issue.UpdateIssueRequest;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserUtil
import com.onresolve.jira.groovy.user.FormField

//point to the CF navigator Team and get the value
def issueManager = ComponentAccessor.getIssueManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def team = customFieldManager.getCustomFieldObject("customfield_14400")
def team_value = issue.getCustomFieldValue(team)

def mIssue = issueManager.getIssueObject(issue.id)

switch (team_value){
case "Data Center Ops":
mIssue.setAssigneeId("x")

break;

case "Data Traffic Engineering & Operations":
mIssue.setAssigneeId("y")

break;

case "Site Reliability Engineering & Storage Engineering":
mIssue.setAssigneeId("z")

break;

case "Sys Ops":
mIssue.setAssigneeId("a")

break;

case "Site Reliability Tools":
mIssue.setAssigneeId("b")

break;

}

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

Admins, notify your Jira instance of system-wide changes with the new admin announcement banner

Hi All! We’re excited to share the launch of an announcement banner that lets Jira site administrators communicate directly to their users across Jira Cloud instance.   📢 Get y...

120 views 6 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you