Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Can I omit a history event using a Groovy listener?

Cynthia K. McNeil November 20, 2011

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");
}

1 answer

0 votes
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.
November 20, 2011

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);

Have a search for sample code on those lines.

Cynthia K. McNeil November 20, 2011

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!

Cynthia K. McNeil November 20, 2011

also my thought is perhaps I can't get to this level with Groovy, will maybe need to code in java to get there?

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.
November 21, 2011

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.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events