Hello guys, im trying to sendo a custom email via script , at the moment my script is :
import com.atlassian.jira.component.ComponentAccessor
import java.util.Map
import com.atlassian.jira.issue.AttachmentManager
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.issue.CustomFieldManager
import com.atlassian.jira.issue.Issue
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("Gestor Imediato")
def recipient = issue.getCustomFieldValue(cf).getEmailAddress()
mail.setTo(recipient)
but i still getting error msg in bold lines, someone know the problem? ty already
What error message are you getting? Is it possible that the custom field is empty and returning null. This would cause an error when you call getEmailAddress. You could write this line as
def recipient = issue.getCustomFieldValue(cf)?.getEmailAddress()
This would return null to recipient if the field is empty. Then you would need to handle the null value.
Bu the way, getCustomFieldObjectByName is deprecated, so you might want to get into the habit of using getCustomFieldObjectsByName("Gestor Imediato")?.getAt(0), which does the same thing.
Hi @Derek Fields _RightStar_ ,
i have one similar requirement, "need to send the notifications to users in a multi picker field
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @RichardA
Thy this:
final String cf = "UserPickerMultiSelect"
def customFieldManager = ComponentAccessor.customFieldManager
def cfObject = customFieldManager.getCustomFieldObjects(issue).find { it.name == cf }
def cfValList = issue.getCustomFieldValue(cfObject)
def emailAddr = cfValList*.getEmailAddress().join(",") // provides email address of users selected in UserPickerMultiSelect custom field.
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.