Skip to end of banner
Go to start of banner

Last comment scripted field

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Problem

You want to show the last comment made on an issue as a custom field so that it will display in the issue results list or on an issue sidebar.

Solution

Display comment text only

JComment lastComm = getLastComment(key);
return lastComm.text;

The field will display nothing if no comments have been made on the issue.

Display comment text only with default for no comment

JComment lastComm = getLastComment(key);

if(isNotNull(lastComm.author)) {
    return lastComm.text;
} else {
    return "No comment has been left on this issue.";
}

Display the authors name followed by the comment text

JComment lastComm = getLastComment(key);
return userKeyToDisplayName(lastComm.author) + ": " + lastComm.text;

Example output: Jonathan Muse: I don’t understand why Jon always gets the last taco.

Display the authors name followed by comment date and text

JComment lastComm = getLastComment(key);
return userKeyToDisplayName(lastComm.author) + + " (" + formatDate(lastComm.created, "MM-dd-yyyy") + "): " + lastComm.text;

Example output: Jonathan Muse (03-25-2024): I don’t understand why Jon always gets the last taco.

  • No labels