How to set Group name based on IssueType and Custom field value?

Teja April 5, 2016

I have a custom field called "Environment" which lists values called "Prod" "Preprod" "Supp".

If user selects Scenario 1: IssueType eg: "Enhancement" and cfvalue Environment = "Prod" I need to set Group name automatically to "Jira-Developers".

Scenario 2: IssueType eg: "Enhancement" and cfvalue Environment = "PreProd" I need to set Group name automatically to "Jira-Admin".

Scenario 3: IssueType eg: "TasK" and cfvalue Environment = "Prod" I need to set Group name automatically to "Jira-Police".

image2016-4-6 11:1:49.png

How to do that..?

 

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2016
import com.atlassian.jira.component.ComponentAccessor

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def groupManager = ComponentAccessor.getGroupManager()

def envCf = customFieldManager.getCustomFieldObjectByName("Environment")
def groupCf = customFieldManager.getCustomFieldObjectByName("Group name")

if (issue.issueType.name == "Enhancement" && issue.getCustomFieldValue(envCf)?.value == "Prod") {
    def group = groupManager.getGroup("Jira-Developers")
    issue.setCustomFieldValue(groupCf, group)
}

Untested. Check all those strings. Put that as the first post-function.

As you didn't specify, I assumed JIRA 7+, and that Environment is a select list field.

 

Teja April 5, 2016

Hi Jamie,

Thanks for the answer but it still shows some exception. Can you please

image2016-4-6 14:50:19.png

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2016

Don't worry about that, just try it.

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2016
Teja April 6, 2016

Thanks Jamie.

Teja April 12, 2016

Hi Jamie,

I am able set Group name to Jira-Developers, but it is not validating properly. [And Environment field is a multiselect custom filed.]

Can you help on this.?

Thanks

JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 12, 2016

When you accept an answer you're saying it works for you. I don't know what you mean by "but it is not validating properly" - you need to give enough information for people to help without having to ask you lots of additional questions, which discourages people from helping.

1 vote
Fidel Castro
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 5, 2016

Hi Teju,

Is Group name a Group Picker custom field?

TAGS
AUG Leaders

Atlassian Community Events