Below script works only under 'All Events' or 'Generic Event'. I have set it to 'Issue Commented', and 'Issue Updated' without any luck.
Only works during workflow events. I haven't set it to any workflows though. It probably only works because of the 'Generic Event' that is fired from the workflow transitions. Do I need to update the script to work with other events? like edit issues, commented etc.
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
def userManager = ComponentAccessor.getUserManager()
def componentManager = ComponentAccessor.getProjectComponentManager()
def componentLead = userManager.getUserByKey(componentManager.findComponentsByIssue(issue)[0].getLead());
log.info(componentLead);
issue.setAssignee(componentLead)
Hello @Sidh Regmi
And welcome to the community :)
The thing is that whenever you update or comment issue during transition, all these actions attached to the event that fires in this transition.
So if you need to catch changes in specific transition, you need to fire specific event, that you ll be catch in your listener.
Thanks Mark !
I am actually trying to run this when an issue is edited. Meaning this is for when components field is edited. Shouldn't the 'Issue Updated' event be triggered when editing a field?
I am using the script in 'Custom script listeners'
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yes, when you re edit issue, Issue Updated will be trigger.
And to catch changes you need code like this:
def change = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find {it.field == "Component"} if (change) { log.debug "Value changed from ${change.oldstring} to ${change.newstring}" // your actions if the field has changed }
change.newstring contains new value
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.