Hi All
Is there any way to find out that how to check a story which has been linked to an Epic is removed or unlinked from the epic using Listener?
My requirement is i have a custom field in story called "applications" which holds few data, and same data is present in epic field too.
so when i will remove or unlink a story from epic it should remove the data too from the epic.
so my plan is to bring all values of all stories linked to epic and store it some where then will check with epic custom field values.
so for that i need to check how can it will be triggered or i will know that a story has been removed from the epic,?
below is my code
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.bc.issue.IssueService
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.issue.IssueInputParameters
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.customfields.option.Option
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.bc.issue.search.SearchService
import org.apache.log4j.Logger
Issue epicIssue = event.issue
String issuetype = epicIssue.getIssueType().getName()
if(issuetype == "Epic"){
if (event?.getChangeLog()?.getRelated("ChildChangeItem")?.find { it.field == "Impacted Application/s" }) {
def changeItem = event?.getChangeLog()?.getRelated("ChildChangeItem")?.find { it.field == "Impacted Application/s" }
def issueManager = ComponentAccessor.getIssueManager() ;
def userManager = ComponentAccessor.getUserManager()
ApplicationUser admin = userManager.getUserByName("INT_JIRA")
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchService = ComponentAccessor.getComponent(SearchService)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def query1 = "\"Epic Link\" in (${epicIssue.key}) AND issuetype = Story"
SearchService.ParseResult parseResult1 = searchService.parseQuery(admin, query1)
def result1 = searchService.search(admin, parseResult1.getQuery(), PagerFilter.getUnlimitedFilter())
def issue1 = result1.getResults()
log.debug("Getting Issues1 values :--------"+issue1)
}
}
Regards
Manas