Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

script runner mail handler add comment to existing issue

Omprakash Thamsetty
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.
August 1, 2019

I am using the script runner Mail Handler option to read the email and create issue or add comment. How  I can add the code to add comment in my script.

 

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

if (issue) {
return
}

 

When issue find in in if statement then I needs to add comment. What needs to be in that to add comment?

 

Thanks

1 answer

1 accepted

0 votes
Answer accepted
Bob
Contributor
August 2, 2019

Hi Omprakash, 

Insert the comment instead of the return. Something like this; 

import com.atlassian.jira.issue.comments.CommentManager

def subject = message.getSubject() as String

def issue = ServiceUtils.findIssueObjectInString(subject)
def body = MailUtils.getBody(message)
ApplicationUser reporter = messageUserProcessor.getAuthorFromSender(message) ?: user

if (issue) {
def comment = subject + " - " + body
commentManager.create(issue, reporter, comment, false)
}

 

If someone knows how to include e-mail sent date, I'd love to hear about it :)

 

Omprakash Thamsetty
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.
August 2, 2019

@Bobone last thing how do we set reporter value to one of Text single line custom field ?  I need to set this on create for one of custom field. Like "reporter" needs to update in "Contact Name"

Omprakash Thamsetty
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.
August 5, 2019

@Bob 

How do we get incoming mail handler sender full name? do we have some thing like

Message. RecipientType .FROM  

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events