Hello all, please help to solve the problem.
I use JMWE add-on
I have 3 components (componentA,componentB,componentC)
I have 3 issues which have constants in their descriptions
issue A: description containce text "cityA"
issue B: description containce text "cityB"
issue C: description containce text "cityC"
how to select componentA for all issues which have text "cityA" ?
If you want to set the Components field automatically during issue creation based on the Description, you can use a Set Field Value post-function on the Create transition, with a Groovy Expression value such as:
if (issue.get("description")?.contains("cityA"))
return "componentA"
if (issue.get("description")?.contains("cityB"))
return "componentB"
//etc for the other cities
return null; //if description contains none
I have script like this, but when i use it in JMWE postfunction issue create it did not selects right component
import com.atlassian.jira.project.Project
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.DefaultUserManager
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.fields.CustomField
MutableIssue issue = issue
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def project = issue.getProjectObject()
def compA = projectComponentManager.findByComponentName(project.getId(), "componentA");
def compB = projectComponentManager.findByComponentName(project.getId(), "componentB");
def compC = projectComponentManager.findByComponentName(project.getId(), "componentC");
if(compA != null && issue.getAsString("description").contains ("Location: cityA")){
issue.setComponent([compA])
}
if(compB != null && issue.getAsString("description").contains ("Location: cityB")){
issue.setComponent([compB])
}
if(compC != null && issue.getAsString("description").contains ("Location: cityC")){
issue.setComponent([compC])
}
Maybe I do someth wrong ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Artur Sox
you didn't specify if you are on Jira Server or Cloud.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
And at what point would you like to set the component based on the description? During issue creation? During another transition?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello @Artur Sox
You can use the post-function in the JMWE plugin
here's the docs
https://innovalog.atlassian.net/wiki/spaces/JMWE/pages/68878480/Set+field+value
You can choose the component field and use the groovy expression to check if the description contains the string "cityA" and then set the relevant component.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please see here
https://innovalog.atlassian.net/wiki/spaces/JMWE/pages/113311862/Accessing+the+fields+of+an+issue
You can access the description field and check if the string contains the value "cityA"
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.