How to get the timestamp of the first public comment made?

Marc Jason Mutuc
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.
March 11, 2024

I'm using JMCF on both Cloud and DC.

On DC I have a field that gets the time stamp for the first comment.

Script is 

issue.get("comment").find{!it.isInternal()}?.created

I cannot get this to work on Cloud. Please help. Thanks!

3 answers

1 accepted

1 vote
Answer accepted
Neel Mohapatra _Appfire_ March 11, 2024

Hi @Marc Jason Mutuc 

Yes, you can get a similar result in the cloud with the help of the code below.

Please try and let me know if it helps.

const createdAt = await api.issue.getField(issue, "comment"); 
let firstCommentDate = null;
if (createdAt && createdAt.comments && createdAt.comments.length > 0) {
for (const comment of createdAt.comments) {
if (comment.jsdPublic === true) {
firstCommentDate = comment.created;
break;
}
}
}

console.log("First comment created date where 'jsdPublic' true:", firstCommentDate);

return firstCommentDate;

 
Regards,
Neel

Marc Jason Mutuc
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.
March 11, 2024

Thank Neel! It works on the field and when tested. But it does not get displayed via filters/issue navigator.

Also, any documentation you could point me to for these? 

Marc Jason Mutuc
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.
March 11, 2024

Apologies. I'm using a Scripted datetime field.

It's giving this error message when tested.

 

The script result looks like it isn't assignable to this type of field.
Console output is
First comment created date where 'jsdPublic' true:, 2024-03-11T17:59:37.732+0800
Marc Jason Mutuc
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.
March 11, 2024

Ah. Just added 

return firstCommentDate

Your code works. Thank you very much!

0 votes
Hannes Obweger - JXL for Jira
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
March 23, 2024

Hi @Marc Jason Mutuc

just as food for thought: Depending on your exact requirements, there may be apps available in the Atlassian Marketplace that can provide a simpler and more optimised solution for what you're looking for.

If you'd be open to this, you may want to have a look at the app that my team and I are working on, JXL for Jira.

JXL is a full-fledged spreadsheet/table view for your issues that allows viewing, inline-editing, sorting, and filtering by all your issue fields, much like you’d do in e.g. Excel or Google Sheets. It also comes with a number of so-called smart columns that aren’t natively available, including the date of the first external comment, and many other comment-related columns.

This is how it looks in action:

first-external-comment.gif

As you can see above, you can easily sort and filter by your comment columns; you can  also use them across JXL's advanced features, such as support for (configurable) issue hierarchies, issue grouping by any issue field(s), sum-ups, or conditional formatting.

This all just works - there's no scripting or automation whatsoever required.

Any questions just let me know,

Best,

Hannes

0 votes
Erik Flees
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
March 22, 2024

I use a couple of customer fields and an automation.

I create a number field called "Time to First Response" and a Date Time field called "First Response Time".

Here is the automation I use.

2024-03-22_14h01_24.png

Here is the Then: edit issue fields step.2024-03-22_14h04_39.png

Here is the And: edit issue fields step.

2024-03-22_14h04_57.png

I hope this helps.

Suggest an answer

Log in or Sign up to answer