I am testing the ability to add users to the requested participant field using scriptrunner. The concept is check each entry of the Stakeholder Contact field, and if not found in Requested Participant field, add it to the list.
It seems this is close, but I can't seem to figure out why I am getting duplicate entries in the return of the Requested Participant field when testing this.If a user already exists in the Requested Participant field it seems to add them anyway. I would think the if statement would cover that scenario?
import com.atlassian.jira.component.ComponentAccessor;
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def stakeholderContact = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Stakeholder Contact"),
requestParticipants = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Request participants")
def sc = issue.getCustomFieldValue(stakeholderContact) as List,
rp = issue.getCustomFieldValue(requestParticipants) as List
sc.each{
if (rp.any {it}) rp << it
}
return rp
This will be a post function, but for this particular context it's in a scripted field (I use these to test results before adding post-functions)
Any help would be appreciated.