Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.
×Hi,
I am trying to achieve the same.
Based on research I have code which gives me the issue keys but does not know how to add comments to this. Some errors I got referring to the arrays that could not be created.
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.search.SearchProvider
import com.atlassian.jira.jql.parser.JqlQueryParser
import com.atlassian.jira.web.bean.PagerFilter
import com.atlassian.jira.component.ComponentAccessor
def jqlQueryParser = ComponentAccessor.getComponent(JqlQueryParser.class)
def searchProvider = ComponentAccessor.getComponent(SearchProvider.class)
def customFieldManager = ComponentAccessor.customFieldManager
def issueManager = ComponentAccessor.issueManager
def commentManager = ComponentAccessor.getCommentManager()
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def query = jqlQueryParser.parseQuery("project = XXX and labels = YYY")
def issue_results = searchProvider.search(query, user, PagerFilter.getUnlimitedFilter())
def issueList = issue_results.issues.collect{issueManager.getIssueByCurrentKey(it.key,)}
issueList.each{
def issue = it as MutableIssue
}
If you could help I am thrilled.
Best,
Simon
How would you expect JIRA to show this information?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Actually I would like to analyze the content of the last comment and check if I was mentioned there (@username). I would like to get a list of issues where I was mentioned in the last comment.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It sounds like you're looking to create a JQL function then? You'd like to write a query like issueFunction in mentionedInLatestComment(currentUser()) and be returned a list of issues that match this function?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're looking for this ScriptRunner module: https://scriptrunner.adaptavist.com/latest/jira/custom-jql-functions.html
I have created JQL functions to search on Projects, Users, and Versions before, but I haven't tried to extract @mentions from comments.
You're likely going to need to use CommentManager.getLastComment(Issue issue) to obtain the last comment for each issue, then you can use Comment.getBody() to obtain the comment text. Finally, you can parse the content to search for the mention format, which is stored like this: [~username]. Once you extract this, you can compare the mentions to the argument passed to the JQL function.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.