I've played with this for too long now, but can't seem to figure it out. It's working fine in the console, but when I add it as a post function to the create transition, it shows success, but doesn't seem to store to the database. Thanks in advanced for any help you're able to provide! I've been looking through other posts and trying different tweaks, but nothing seems to be doing the trick.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def requestParticipantsField = customFieldManager.getCustomFieldObject("customfield_10001")
def poc = customFieldManager.getCustomFieldObject("customfield_10506")
List<ApplicationUser> pocvalues = issue.getCustomFieldValue(poc) as List
ArrayList<ApplicationUser> userList = new ArrayList<ApplicationUser>()
pocvalues.each {
if(it)
{ userList.add(it) }
}
return userList
MutableIssue myIssue = issue
myIssue.setCustomFieldValue(requestParticipantsField, pocvalues);
Below are the steps I have the post functions running:
Hi Carol,
Do you still need help with this? I would perhaps try using updateValue(), as it will persist the change to the database.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
def requestParticipantsField = customFieldManager.getCustomFieldObject("customfield_10001")
def poc = customFieldManager.getCustomFieldObject("customfield_10506")
List<ApplicationUser> pocvalues = issue.getCustomFieldValue(poc) as List
ArrayList<ApplicationUser> userList = new ArrayList<ApplicationUser>()
pocvalues.each {
if(it)
{ userList.add(it) }
}
//return userList
//MutableIssue myIssue = issue
//myIssue.setCustomFieldValue(requestParticipantsField, pocvalues)
requestParticipantsField.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(requestParticipantsField), userList),new DefaultIssueChangeHolder())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.