Hello everyone,
I am trying to propagate to parents the fact that I flag a subtask.
I have created a first version of a Listener.
I am on it since 3 days, trying every way I know to update an issue. Everywhere I can read that I just need to change custom field "Flagged" but I can not make it work, it is never saved.
I have an other version using ModifiedValue that does not work either.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.event.type.EventDispatchOption
def issue = event.issue
def change = event.changeLog.getRelated("ChildChangeItem").find {it.field == "Flagged"}
if (!change) {
return
}
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def comment = event.comment
def parent = (MutableIssue) issue.parentObject
def customFieldManager = ComponentAccessor.customFieldManager
def optionsManager = ComponentAccessor.optionsManager
def issueManager = ComponentAccessor.issueManager
def cf = customFieldManager.getCustomFieldObjects(issue).find {
it.name == 'Flagged'
}
def fieldConfig = cf.getRelevantConfig(parent)
def value = optionsManager.getOptions(fieldConfig)?.find {
it.toString() == 'Impediment'
}
def changeHolder = new DefaultIssueChangeHolder();
if (change.newstring == "Impediment") {
log.warn ("issue: " + issue.key + " has been Flagged with comment: " + comment)
parent.setCustomFieldValue(cf, [value])
issueManager.updateIssue(user, parent, EventDispatchOption.ISSUE_UPDATED, false)
log.warn ("Should have flagged parent issue: " + parent.key + " with value: " + value)
} else {
log.warn ("issue: " + issue.key + " has been Unflagged with comment: " + comment)
}
I also found this: https://docs.atlassian.com/jira-software/6.7.6/com/atlassian/greenhopper/service/issue/flagging/FlagService.html
But it seems that this API does not exist anymore since the compiler can not find "com.atlassian.greenhopper.service.issue.flagging.FlagService"
Does any one have any idea?
Thank you very much