Help with the script, I need to add the user to the field when creating the task, if two values are selected in the field, field I use Selection List (Drop Down)
i'm using script runner
and i have script:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.jira.user.ApplicationUser
ApplicationUser currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def cf = ComponentAccessor.customFieldManager.getCustomFieldObject(10032L); //Соисполнители
def arrayOfComponents = issue.getComponents();
def userList = getCustomFieldValue(issue,10032L)?:[];
for(def comp in arrayOfComponents){
if(comp.getName()=="Email (Почта)"){
userList += [getUser("r.sheraliev")];
}
if(comp.getName()=="FTP (Uzmobile)"){
userList += [getUser("a.malikov")];
}
if(comp.getName()=="AD (Домен)"){
userList += [getUser("o.gulomkodirov")];
}
if(comp.getName()=="JIRA (Confluence)"){
userList += [getUser("m.zaxidov")];
}
if(comp.getName()=="Local Administartor"){
userList += [getUser("o.shodmonov")];
}
if(comp.getName()=="Oasis"){
userList += [getUser("a.malikov")];
}
}
issue.setCustomFieldValue(cf, userList.collect{it})
ComponentAccessor.getIssueManager().updateIssue(currentUser, issue, EventDispatchOption.ISSUE_UPDATED, false)
ApplicationUser getUser(String userName){
return ComponentAccessor.getUserManager().getUserByName(userName)
}
def getCustomFieldValue(issue, Long fieldId) {
issue.getCustomFieldValue(ComponentAccessor.customFieldManager.getCustomFieldObject(fieldId))
}
this script add users to user rist if components use
If i select from field Responsible Services "Branch (Infosystems)" and in the second fieled "AD (Домен)" script must add users to users fieled list