could some1 please help me. We are trying to sent a notification to participants. We already have a script to add participants to issue when field contains value.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.IssueManager
import java.util.ArrayList
import com.atlassian.jira.user.ApplicationUser
import org.apache.log4j.Logger
//def log = Logger.getLogger("com.acme.XXX")
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def REQUEST_PARTICIPANTS_FIELD = "customfield_10101"
def REQUEST_CURRENCY_FIELD = "customfield_11800"
//def PRIMARY_USER_FIELD = "customfield_10913"
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueManager = ComponentAccessor.getIssueManager()
MutableIssue myIssue = issue
// For testing in the Script Console, hard-code an issue object.
//MutableIssue myIssue = issueManager.getIssueObject("SFIN-24")
// Get custom field objects.
def requestParticipantsField = customFieldManager.getCustomFieldObject(REQUEST_PARTICIPANTS_FIELD)
def requestCurrencyField = customFieldManager.getCustomFieldObject(REQUEST_CURRENCY_FIELD)
def requestCurrencyFieldValue = myIssue.getCustomFieldValue(requestCurrencyField)
if ("${requestCurrencyFieldValue}" != 'CZK')
{
// add defined users as participants
ApplicationUser user_a = ComponentAccessor.getUserManager().getUserByName("annawais")
ApplicationUser user_b = ComponentAccessor.getUserManager().getUserByName("jhobziko")
// Add initial Reporter to array.
ArrayList<ApplicationUser> participants = []
participants.add(user_a)
participants.add(user_b)
// Update the Request Participants field.
myIssue.setCustomFieldValue(
requestParticipantsField,
participants
)
// Store to database.
try {
issueManager.updateIssue(
currentUser,
myIssue,
EventDispatchOption.ISSUE_UPDATED,
false
)
} catch (Exception e) {
log.debug "Exception: " + e
}
}
Anyone have an idea how to add an email this issue to this script?
Thank you
KD
Martin