Hi,
I have a Scriptrunner job that runs every 24h. If the JQL Statement finds issues, for everyone of them an email should be send. That works fine for me.
But every issue has a customfield with a user stored within.
How can I get this username for the issue that the jql statement just found?
I got this code, but here I need to specify the issue myself.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.project.Project
def issueManager = ComponentAccessor.issueManager
def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_11402")
def issue = issueManager.getIssueByCurrentKey("PER-289")
def value = (String) issue.getCustomFieldValue(customField)
log.warn(value)
And the second question is:
How do I get the email address from the user I just found in the customfield?
For project role users I used this very good working code. But the role stay the same over the whole project. So that was "easy".
// Get all the mail addresses from the role members of a project
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
def projectRole = projectRoleManager.getProjectRole("Sales")
def project = ComponentAccessor.getProjectManager().getProjectObjByKey("PER")
def usersInRole = projectRoleManager.getProjectRoleActors(projectRole, project).getApplicationUsers()*.emailAddress.join(",")
Thanks for reading my stuff