In Jira Cloud, have the JMCF app by AppFire and trying to create a scripted field to display the last comment body, date and author. When I test, I recieve this error:
TypeError: Cannot read property 'comments' of undefined in script at line 2, column 37
// Get the comments from the issue
var comments = issue.fields.comment.comments;
if (comments && comments.length > 0) {
// Get the last comment
var lastComment = comments[comments.length - 1];
// Extract the details
var lastCommentBody = lastComment.body;
var lastCommentDate = lastComment.created;
var lastCommentAuthor = lastComment.author.displayName;
// Format the output
var result = "Last Comment: " + lastCommentBody + "\n" +
"Last Comment Date: " + lastCommentDate + "\n" +
"Last Comment Author: " + lastCommentAuthor;
// Return the result
return result;
} else {
return "No comments available.";
}