It's not the same without you
Join the community to find out what other Atlassian users are discussing, debating and creating.
Hi!
I have a some problem with my groovy script. I try to set component in post-function, but it doesn't work:
import org.apache.log4j.Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction") ComponentManager componentManager = ComponentManager.getInstance() MutableIssue issue = issue ProjectComponent component = componentManager.getProjectComponentManager().findByComponentNameCaseInSensitive("MyComponent") issue.setComponentObjects([component.getName()])
Hey Kate, I figured out the answer about two weeks ago. Sorry I didn't reply any faster!
Here is the script:
import com.atlassian.jira.ComponentManager 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 import com.atlassian.jira.util.ImportUtils import com.atlassian.jira.user.util.DefaultUserManager import com.atlassian.crowd.embedded.api.User import com.atlassian.jira.project.Project MutableIssue issue = issue Project project = issue.getProjectObject() def component = componentManager.getProjectComponentManager().findByComponentName(project.getId(),'ComponentName') issue.setComponentObjects([component])
What happens? Do you get any errors in the logs? Does it save? I had to call issue.store() after all the set functions to get it to save.
Also check the order of your post function. It's important.
Hi all,
hope anyone can help me.
I made a post funcion when a issue is created to assign a component if the issue reporter is someone specific.
It seems that everything work well but, when I open the issue, the component is unset.
Does anybody can help me?
Here is my post function:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.ComponentManager
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
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.user.util.DefaultUserManager
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.project.Project
MutableIssue issue = issue
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def project = issue.getProjectObject()
def componentSicurezza = projectComponentManager.findByComponentName(project.getId(), "CSR Sicurezza");
def componentSistemi = projectComponentManager.findByComponentName(project.getId(), "CSR Sistemi");
def componentPuc = projectComponentManager.findByComponentName(project.getId(), "CSR PUC");
def reporter = issue.reporter?.name
if (reporter == "emailhandlerSicurezza") {
issue.setComponentObjects([componentSicurezza])
}
if (reporter == "EmailSenderSistemi") {
issue.setComponentObjects([componentSistemi])
}
if (reporter == "emailhandler") {
issue.setComponentObjects([componentPuc])
}
issue.store()
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.
Read moreHey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...
Connect with like-minded Atlassian users at free events near you!
Find a groupConnect with like-minded Atlassian users at free events near you!
Unfortunately there are no AUG chapters near you at the moment.
Start an AUGYou're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.