update custom field based on summary value

Michael Blake July 5, 2018

how do I update a custom field when the summary of the issue is "Training Issue" and issue type is a subtask using a script listener

1 answer

0 votes
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 5, 2018

Hello,

It would be like this:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption

def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObjectByName("your field name")
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def issue = event.issue

if ((issue.getSummary == "Training Issue") && (issue.getIssueType().isSubtask())) {
issue.setCustomFieldValue(cf, "your value")
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
}

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events