Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Copy text field value to set Reporter in post-function

debraj.neogi@tesco.com September 3, 2020

We have a customer email field (text single line) that is being filled by users while creating feedback on JIRA. We need to create a post-function which will automatically set the Reporter based on the inputs of this text field. Is there a simple groovy script available which we can refer? Thanks for your help.

1 answer

0 votes
Gustavo Félix
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.
September 3, 2020

Hi debraj.neogi@tesco.com 
You can take this as a reference, I'm using ScriptRunner.

def userManager = ComponentAccessor.getComponent(UserSearchService)
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
IssueManager issueMAnager = ComponentAccessor.getIssueManager()

def issue = issue as MutableIssue
def emailField = customFieldManager.getCustomFieldObjectByName("email")
def email = issue.getCustomFieldValue(emailField)

ApplicationUser reporter = userManager.findUsersByEmail(email.toString()).getAt(0)

issue.setReporter(reporter)
issueManager.updateIssue(user,issue,EventDispatchOption.DO_NOT_DISPATCH,false)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events