Hi!
I am trying to add a automaticlly generated comment on an issue when it is transitioned. The comment should "tag/reference" a user that is stored in a single select user picker.
I almost got this working, but i am missing the last step.
My user is returned as a string and not an object. In the format "username(username)".
Is there a way to get the plain username?
And is it at all possible to add a comment that references a user? (Like adding a @username manually).
My post function script looks like this:
// Required Imports
import com.atlassian.jira.component.ComponentAccessor;
// Get a pointer to the current logged in user
def CurrentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
// Get the current Issue
def issue = issue;
// Get the Manager classes required
def commentManager = ComponentAccessor.getCommentManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager();
//Get the tester user from customfield
def customField = customFieldManager.getCustomFieldObjectByName("Reviewer"); //customfield_10304
if(customField) {
String user = issue.getCustomFieldValue(customField);
if(user) {
def CommentText = "Review requested @${user}";
commentManager.create(issue,CurrentUser,CommentText,true);
}
}
Thanks in advance!