issuetype = "SW Bug" AND affectedVersion in versionMatch("MP1_A00*") AND status not in (Closed,"REVIEW VERIFICATION@AS","In Verification@Stakeholder")
for this i wrote listener script
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.project.VersionReleaseEvent
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.project.version.Version
if (event instanceof VersionReleaseEvent) {
def version = event.getVersion()
def project = version.getProject()
def versionPattern = /\bMP1_A00[a-zA-Z0-9_]*\b/
if (version.name ==~ versionPattern) {
def issueManager = ComponentAccessor.getIssueManager()
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def jqlQuery = 'issuetype = "SW Bug" AND affectedVersion in versionMatch("MP1_A00*") AND status not in (Closed, "REVIEW VERIFICATION@AS", "In Verification@Stakeholder")'
def query = jqlQueryParser.parseQuery(jqlQuery)
def searchService = ComponentAccessor.getComponent(SearchService)
def searchResults = searchService.search(user, query, PagerFilter.getUnlimitedFilter())
searchResults.results.each { issue ->
def mutableIssue = issueManager.getIssueObject(issue.id) as MutableIssue
def currentVersions = new HashSet<Version>(mutableIssue.getAffectedVersions())
if (!currentVersions.contains(version)) {
currentVersions.add(version)
mutableIssue.setAffectedVersions(new ArrayList<Version>(currentVersions))
// Logging for testing
log.warn "Updating issue ${mutableIssue.key} with version ${version.name}"
issueManager.updateIssue(user, mutableIssue, EventDispatchOption.DO_NOT_DISPATCH, false)
// Ensure issue is correctly updated and indexed
def issueIndexingService = ComponentAccessor.getComponentOfType(com.atlassian.jira.issue.index.IssueIndexingService)
issueIndexingService.reIndex(mutableIssue)
}
}
}
}
it is updating the latest version in the Affects Version/s field but the exact issue is if i am trying to edit the Affects Version/s field the version is no longer available.
Could you please help me out.
Thanks in Advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.