Hello,
we need to add each commentor to the Participants (we have custom field for this) in the issue.
As I know it can be done using Listeners in a ScriptRunner plugin.
Now script is like
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
def issue = event.issue as MutableIssue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObject(10600)
def lastcomment = event.getComment()
def commentAuthor = lastcomment.getAuthorApplicationUser()
issue.setCustomFieldValue(cf, commentAuthor)
It has no any errors, but commentors don`t appear in a Participants.
What`s wrong in the script ?
Thank you for your answers and help!
Is the "Participants" field the one from the Jira toolkit, or is it just a multi-user select field?
Ok, great, that's completely clear and explains the problem.
The value of a multi-user field is not a single user, it is a list of users. You need to get the current list, add to it and post it back. Not set it to a single user. Even if it could accept a single user (it can't, it needs a list, even if that list is 0 or 1 items long), that would wipe out the current list.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, Nic.
Thank you for your advice.
Now it works
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.util.IssueChangeHolder
import com.atlassian.jira.user.ApplicationUser
IssueChangeHolder changeHolder = new DefaultIssueChangeHolder()
def issue = event.issue as MutableIssue
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def cf = customFieldManager.getCustomFieldObject(10600)
def lastcomment = event.getComment()
def commentBody = lastcomment.getBody()
def commentAuthor = lastcomment.getAuthorApplicationUser()
List<ApplicationUser> participants = [];
if (commentAuthor != issue.reporter){
ApplicationUser user = commentAuthor
participants.add(user);
}
if (commentAuthor != issue.assignee){
ApplicationUser user = commentAuthor
participants.add(user);
}
if (commentAuthor == issue.reporter){
return 0
}
if (commentAuthor == issue.assignee){
return 0
}
cf.updateValue(null, issue, new ModifiedValue(issue.getCustomFieldValue(cf), participants), changeHolder)
It could be more "code friendly", but it works like expected.
May be it will be useful for someone.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.