Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Use the operator's value to update custom fields

zhaoyawei April 23, 2018
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.watchers.WatcherManager
import com.atlassian.jira.user.ApplicationUser

def jiraAuth = ComponentAccessor.getJiraAuthenticationContext();
def thisUser = jiraAuth.getUser();
def issue = event.getIssue();

IssueManager issueManager = ComponentAccessor.getIssueManager();
WatcherManager watcherManager = ComponentAccessor.getWatcherManager();
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
MutableIssue mutableIssue = issueManager.getIssueObject(issue.getkey())
Collection<ApplicationUser> appList = [];
issue.getAssigneeUser().directoryUser
issue.getExternalFieldValue(issue.getAssigneeId())
def cf = customFieldManager.getCustomFieldObject("当前处理人2");
if (issue.getCustomFieldValue(cf)) {
Collection<ApplicationUser> list = issue.getCustomFieldValue(cf) as Collection<ApplicationUser>;
if (list.size()>0) {
def user = list?.getAt(0).getDirtoryUser();
mutableIssue.setCustomFieldValue(cf,user)
// mutableIssue.setAssignee(user);a
appList.addAll(list);
appList.add(thisUser);
for(ApplicationUser applicationUser : appList) {
watcherManager.startWatching(applicationUser,issue);
}
issueManager.updateIssue(event.getUser(),mutableIssue, EventDispatchOption.ISSUE_ASSIGNED,false);
}
}

1 answer

0 votes
zhaoyawei April 23, 2018

Both the handler and the current handler 2 can get this, how do I use the handler to update the current handler 2 (the current handler 2 is a custom field)

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events