Hello all, I'm trying to use scriptrunner to create a listener that triggers when the "Target start" field (from advanced roadmaps) on an Epic is updated. The goal is to update the same field on all of that epic's children.
I attached the script below to a listener and it fires when I make a change to the field, but the field on the epic's children are not updating. The "setCustomFieldValue()" and "updateIssue()" in the if(change) block are both throwing errors:
cannot find matching method com.atlassian.jira.issue.Issue#setCustomFieldValue(com.atlassian.jira.isue.field.java.lang.Object). Please check if the declared type is correct and if the method exists
I don't know how to either resolve this, or set the field using a different method.
-------------------
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.util.ImportUtils
import com.atlassian.jira.issue.index.IssueIndexingService
import com.atlassian.jira.event.type.EventDispatchOption
def linkType = "Issue in Epic"
def linkMgr = ComponentAccessor.issueLinkManager
def cfManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def issueIndexingService = ComponentAccessor.getComponent(IssueIndexingService.class)
def issue = event.issue
def currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def TSField = cfManager.getCustomFieldObjects(issue)?.find{it.name == "Target start"}
def cfValue = issue.getCustomFieldValue(TSField)
def epicLink = cfManager.getCustomFieldObjectByName("Epic Link")
def epicName = cfManager.getCustomFieldObjectByName("Epic Name")
def change = event?.changeLog?.getRelated("ChildChangeItem")?.find{it.field == TSField}
if (!change){
return
}
def linkedIssue = linkMgr.getOutwardLinks(issue.id).findAll{it.issueLinkType.name == linkType}
if (!linkedIssue){
return
}
if (change){
linkedIssue.each{
def linkedIssueObj = it.destinationObject
linkedIssueObj.setCustomFieldValue(TSField, cfValue)
issueManager.updateIssue(currentUser, linkedIssueObj , EventDispatchOption.DO_NOT_DISPATCH, false)
def wasIndexing = ImportUtils.isIndexIssues()
ImportUtils.setIndexIssues(true)
issueIndexingService.reIndex(linkedIssueObj)
ImportUtils.setIndexIssues(wasIndexing)
}
}