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..?
Community moderators have prevented the ability to post new answers.
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.
Don't worry about that, just try it.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Read this if you want to understand why: https://scriptrunner.adaptavist.com/latest/jira/#_providing_type_information
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Teju,
Is Group name a Group Picker custom field?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.