Forums

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

Power Scripts: JQL for Last Comment Date

Chris K
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.
June 23, 2023

Dear Community,

I am currently getting into Power Scripts and SIL, and I am trying to create a JQL function, which allows me to search for current updates on issues via comments. It would be very nice, if there was a possibility to create a custom JQL for Last Comment Date.

I found a similar question + solution for ScriptRunner in this post:

https://community.atlassian.com/t5/Jira-Service-Management/ScripRunner-Script-Fields-Last-Comment-Date-By-Agent-And/qaq-p/1676429

Do you have a recipe how I can solve this via Power Scripts?

Greetings Chris

2 answers

2 accepted

2 votes
Answer accepted
Amelie Winkler _Appfire_
Atlassian Partner
June 26, 2023

Hi @Chris K  – Amelie from the Power Scripts team here! @Mirek suggested a great solution above, using custom fields and setting up a listener.

You can also simply create the JQL using a SIL script:

comment_dateJQL.sil

string [] keys = selectIssues("project = " + argv[0] + " ");
string [] ret;
string format = "MM-dd-yyyy"; //format for date
for(string k in keys) {

JComment lastComment = getLastComment(k);
// runnerLog(lastComment);
// runnerLog(formatDate(lastComment.created, format));

if (formatDate(lastComment.created, format) == "" + argv[1] + "" ) {
ret += k;
}
}
return ret;

(The runnerLog is optional, in case you want to check the output)

argv 0 stands for project key, argv 1 for the search date of the comment (see screenshot attached)

Then you run the JQL search:

key in silJQLList("comment_dateJQL.sil", SPRN, 06-26-2023)

In our documentation, you can learn more about custom JQL Searches and the getLastComment.

Feel free to contact our support team, in case you have any future questions – they're Power Scripts experts and super responsive.

Best, Amelie

 

image.png

Mirek
Community Champion
June 26, 2023

Thank you @Amelie Winkler _Appfire_ for confirming that my my thinking was also good :) I like the alternative solution that you proposed too!

@Chris K I think with both solutions you should be fine now :)

Like # people like this
Chris K
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.
June 26, 2023

Hi @Amelie Winkler _Appfire_ and @Mirek

Thank you for the solutions and the quick response.

At first sight, I prefer the "JQL-script solution", since I don't need to create a new custom field.

This case shows that there are "several ways to rome", I am very happy that you proposed a view :)

Take care and thanks a lot!

Greetings Chris

Like Mirek likes this
2 votes
Answer accepted
Mirek
Community Champion
June 26, 2023

Hi @Chris K 

I think there is an option to achieve it. There should be a getLastComment() function..

https://anovaapps.atlassian.net/wiki/spaces/SIL/pages/1828454/getLastComment

So in SIL Manager you should be able to view information about last comment for a specific issue. Example

string [] comment = getLastComment (ABC-1234);
runnerLog("Got comment:" + comment["date"]);

What you need is a date of this comment which you should now put in a Custom Field so that it could be searched..

So when you create a Date Picker custom field (you can call it as you want e.g Last Comment Date) you should be able to inject this to this field.

https://anovaapps.atlassian.net/wiki/spaces/PSJ/pages/1134133408/Custom+Fields+-+Setting+Values

Just make sure that you note the ID of the field since you need to put a date to it..

customfield_<yourCFIDhere> = comment["date"];

 Now I guess you should be good and use SIL Listener to update the information

https://anovaapps.atlassian.net/wiki/spaces/JJUPIN/pages/1854513/SIL+Listeners#SILListeners-AddingaListener

(As I see there is a event that is related to comments also such as "Issue Commented" so you should be good)

Hope it helps :)

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events