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.
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)
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.