Getting reporter email domain as scripted variable in Scriptrunner cloud

AbrahamA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 7, 2023

Hello

I am trying to create a scripted field which will return me a email address. This is so that I can search based on the scripted field for issues created by a particular email domain.

 

I have tried like this but does not work..

How do I get domain of the reporter.

// Fetch the issue object from the key using the Jira Software API
    def issue = get("/rest/agile/1.0/issue/${issue.key}")
        .header('Content-Type', 'application/json')
        .asObject(Map)
        .body
        
        //String reporterEmailAddress = issue.fields.reporter.emailAddress
        
         // Get the Story Points custom field to use in the script
         
         // Get the field ids
        def fields = get('/rest/api/2/field')
            .asObject(List)
            .body as List<Map>
            
            
        def creatorField = fields.find { it.name == "Creator" }?.id
        
        return creatorField.emailAddress
        //return issue.fields.creator.emailAddress

 

 

Thanks

Abe

1 answer

Suggest an answer

Log in or Sign up to answer
0 votes
Ken McClean
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 4, 2023

Hello:

Is this for Jira Cloud or Jira Server? The Jira Cloud REST API tends to not return user email addresses, as these are considered private information.

This code returns everything available about the reporter:

 

def issue = get("/rest/agile/1.0/issue/${issue.key}")
.header('Content-Type', 'application/json')
.asObject(Map)
.body


def reporterProperties = issue.fields.reporter

return reporterProperties

 

The email address is not an available property. If you're on Jira Server, it's a different story.

TAGS
AUG Leaders

Atlassian Community Events