Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,300,261
Community Members
 
Community Events
165
Community Groups

Scriptrunner how to mention reporter in comment using Postfunction script

Hi would like to know how to mention reporter in the comment in the post function custom script in workflow transition

 

1 answer

0 votes
Andy Rusnak Atlassian Team May 23, 2022
Hi Wajdan,

Thanks for the posting to the Atlassian Community!

If I understand properly what you are attempting to accomplish here, I believe the script I have written below may be able to serve as an example for you. You may need to modify this for your needs, but this may be able to help you get started:

import com.atlassian.jira.component.ComponentAccessor

// Get the Reporter of the Issue
final reporter = issue.reporterUser;

// Set the user that will post the comment to the issue (in this case
// it is the user that transitioned the issue)
def transitionUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser;

// Create your comment text and reference the reporter user.
final String commentText = """This is a comment [~${reporter.getName()}]""";

// Finally post the comment to Issue
ComponentAccessor.commentManager.create(issue, transitionUser, commentText, true);

Others on the Community may have other ways to accomplish this as well, this was just a quick example I put together and validated that it works for a simple case.
If you have any questions related to this or if I have misunderstood your request please let me know and I would be happy to chat further.

Best,
Andy

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Software

An update on Jira Software customer feedback – June 2022

Hello Atlassian Community! Feedback from customers like you has helped us shape and improve Jira Software. As Head of Product, Jira Software, I wanted to take this opportunity to share an update on...

77 views 1 3
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