Scriptrunner how to mention reporter in comment using Postfunction script

Wajdan May 22, 2022

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
Atlassian Team members are employees working across the company in a wide variety of roles.
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
AUG Leaders

Atlassian Community Events