Hello!
I am working on a scripted field that returns one or multiple users, based on the value of another custom field (multi-select list). When I preview the script with an appropriate issue key, the results display perfectly. However, when I look at the issue, there is no value in the field.
The field is present on the appropriate screens and configured for the project / issue type. I feel like I'm close , but is there something I'm missing here? Any help here would be much appreciated.
Here's my code:
import com.atlassian.jira.user.ApplicationUsers
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
def list1 = ["1","2","3"]
def list2 = ["4","5","6"]
def user1 = ComponentAccessor.getUserManager().getUserByName('user1')
def user2 = ComponentAccessor.getUserManager().getUserByName('user2')
def customFieldManager = ComponentAccessor.customFieldManager
def customFieldName = "Group ID"
def customField = customFieldManager.getCustomFieldObjects(issue).findByName(customFieldName)
def customFieldVal = issue.getCustomFieldValue(customField) as List
def cmList = []
customFieldVal.each { it ->
if ( list1?.contains(it.toString())) {
cmList.addAll(user1)
}
if ( list2?.contains(it.toString())) {
cmList.addAll(user2)
}
}
if (cmList == null) {return "custom field not found"}
if (cmList != null) {return cmList}