Hello,
I have written a Groovy Listener that on IssueAssign event, I want to bypass an entry to the history and activity areas. The issue is specifically with the parent. I always have the parent assigned to a user that is a place holder. The subtasks are then the issues that are assigned and worked on. So, if you can accidentally assign the parent to yourself, I have have added to my groovy listener that on an assign or update, that the parent is always signed back to the placeholder assignee regardless. In the history though, it is showing assigned from the placeholder to me and then another entry that is me back to the placeholder. My question is can I somehow make that the whole event not happen in groovy script so I wouldn't see the history event?
public void issueAssigned(IssueEvent event){
MutableIssue parent = (MutableIssue) event.getIssue();
//is this a DQ issue?
if (parent.projectId == 10072){
//is the issue a parent issue?
if (parent.isSubTask() == false) {
parent.assignee = userManager.getUser("devqueue");
System.err.println("full name " + parent.getAssignee().getFullName());
parent.store();
}
try {
Map actionParams = EasyMap.build("issue", parent.getGenericValue(), "issueObject", parent, "remoteUser", componentManager.getJiraAuthenticationContext().getUser(), "dispatchEvent", Boolean.FALSE)
CoreFactory.getActionDispatcher().execute(ActionNames.ISSUE_UPDATE, actionParams);
}
catch (Exception e) {
System.err.println("exception in corefactory");
}
You will have to experiment a bit, but you should be able to just do
issue.assigneeId = "xyz"
issue.store()
You will probably also need to flush the issue cache and reindex...
indexManager.reIndex(issue);
ok, did try that however, the original assignment still shows up in my history, although the listener assingment does not. This is what I changed the code to:
if (parent.isSubTask() == false) {
parent.assignee = userManager.getUser("devqueue");
System.err.println("full name " + parent.getAssignee().getFullName());
parent.store();
boolean wasIndexing = ImportUtils.isIndexIssues();
ImportUtils.setIndexIssues(true);
ManagerFactory.getCacheManager().flush(CacheManager.ISSUE_CACHE, parent)
indexManager.reIndex(parent);
ImportUtils.setIndexIssues(wasIndexing);
}
Can I get to the original assignment and make that not happen as well? Otherwise for audit purposes, i will need to include both (meaning from the placeholder to me and then back from me to placeholder.
Thanks so much for the input!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
also my thought is perhaps I can't get to this level with Groovy, will maybe need to code in java to get there?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Oh you want to remove the original changeitem/changegroup... that's going to be harder but probably possible. I don't see that there's anything you can do in java here that you can't do in groovy, it's not like you can't access some of the API with groovy, but up to you.
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.