Hello,
We are using our own issuetype "Sprint Goal" for scrum purpose, unfortunately there are some people which don;t understand that sprint goal cannot be in more then one sprint. I am trying to use custom listner to delete issue from sprint expect first one. This is test code to just look how it works, but it doesn't work and i don;t know why. Listener works on IssueUpdate event
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.greenhopper.service.sprint.Sprint
import com.atlassian.greenhopper.service.sprint.SprintIssueService
SprintIssueService sprintIssueService
def issue = event.issue
def issueUpdate = (MutableIssue) issue
log.warn "Custom Listener Check! " + issue
log.warn "Custom Listener " + event.getChangeLog().getRelated("ChildChangeItem").find{it.field == "Sprint"}
def igor = ComponentAccessor.getComponent(UserManager).getUserByName("igot")
def cfManager = ComponentAccessor.getComponent(CustomFieldManager)
def sprint = cfManager.getCustomFieldObjectByName("Sprint")
def sprintValue = issue.getCustomFieldValue(sprint)
ArrayList<Sprint> sprints = (ArrayList<Sprint>)issue.getCustomFieldValue(sprint)
log.warn "Custom Listener "+sprints[0]
def primarySprint = sprints[0]
sprints.each(){
if(it != primarySprint){
sprintIssueService.removeIssuesFromSprint(igor, it, [issue] as Collection)
}
}
thanks in advance for help,
Maciej O.