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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner mailhandler script not working

Hi community,

I have take a script for mailhandler from scriptrunner but it seems not to be working. When email are entering, it is commenting.

Here the code below, I have change the ProjectKey and IssueKey:


import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.service.util.ServiceUtils
import com.atlassian.jira.service.util.handler.MessageUserProcessor
import com.atlassian.jira.user.ApplicationUser
import com.atlassian.jira.user.util.UserManager
import com.atlassian.mail.MailUtils

def userManager = ComponentAccessor.getComponent(UserManager)
def projectManager = ComponentAccessor.getProjectManager()
def issueFactory = ComponentAccessor.getIssueFactory()
def messageUserProcessor = ComponentAccessor.getComponent(MessageUserProcessor)

def subject = message.getSubject() as String
def issue = ServiceUtils.findIssueObjectInString(subject)

if (issue) {

ApplicationUser user = userManager.getUserByName("Jason Chung")
ApplicationUser reporter = messageUserProcessor.getAuthorFromSender(message) ?: user
def project = projectManager.getProjectObjByKey("TE")

def issueObject = issueFactory.getIssue()
issueObject.setIssueTypeId(project.issueTypes.find { == "Service Request" }.id)

messageHandlerContext.createIssue(user, issueObject)


Is there other changes that need to be done on the mailhandler itself or on the script?


Best regards,

Jason Li

1 answer

0 votes
Hana Kučerová Community Leader Feb 06, 2021

Hi @Jason Li Ting Chung ,

I'm sorry, but it is not clear to me, what's wrong, what do you mean by "When email are entering, it is commenting." Do you get some sort of error message?

What is suspicious for me after checking your code:

ApplicationUser user = userManager.getUserByName("Jason Chung")

Is "Jason Chung" name of user? Because you need to provide username not name, so probably something like jason.chung. So, please check, that you get user object not null.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Service Management

Why upgrade to Jira Service Management Premium?

We often have questions from folks using Jira Service Management about the benefits to using Premium. Check out this video to learn how you can unlock even more value in our Premium plan.  &nb...

241 views 1 6
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you