Hi,
I am using JIRA 6.0.6 and would like to update a custom field on a step when Assign to me button has been clicked. Is there a way I can acheive that. I know that adding a Listener might help but I can't seem to find any sample code.
Thanks for you help in advance.
Anand
Community moderators have prevented the ability to post new answers.
Hi,
You could use script runner and create a listener on the Issue Assigned event.
And then just set the custom field over some groovy script.
here is an example:
package com.custom
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.AbstractIssueEventListener
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.util.ImportUtils
import org.apache.log4j.Category
class MyCustomListener extends AbstractIssueEventListener {
Category log = Category.getInstance(MyCustomListener .class)
MyCustomListener () {
log.setLevel(org.apache.log4j.Level.DEBUG)
}
@Override
void issueAssigned(IssueEvent event) {
log.debug "${event.getEventTypeId()} EVENT on ${event.issue}:"
Issue issue = event.issue
}
}
Hi Anand,
Its a sample you are looking for
public class MyListenerClass implements InitializingBean,DisposableBean
{
public void afterPropertiesSet() throws Exception
{
eventPublisher.register(this);
}
public void destroy() throws Exception
{
eventPublisher.unregister(this);
}
@EventListener
public void onIssueEvent(IssueEvent issueEvent)
{
if(eventTypeId.equals(EventType.ISSUE_ASSIGNED_ID))
{
// do stuff
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
you can find sample plugin here
https://bitbucket.org/bhushan154/jira-listener-tutorial/src
https://bitbucket.org/atlassian_tutorial/jira-event-listener
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Community moderators have prevented the ability to post new answers.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.