Hi fellow
I have a script that adds the last comment to a custom field called "last comment"
I also add the comment author to the last comment author custom field, and the comment created date/time into a last comment created date/time field.
But in the overview on a dashboard, using a filter result, this tends to get quite wide.
Therefor I want to add the comment author and comment created date time at the bottom of the last comment custom field, preferably on a new line and with a title: "Author : " and "Comment Created Date/time : " before the actual data.
How can I do that?
//Last update by Ward Schwillens at 11/03/2024 11.32
final ProjectReportCommentFieldName = 'Project Report Comment'
final lastProjectReportCommentAuthorFieldName = 'Last Project Report comment author'
final lastProjectReportCommentDateTimeFieldName = 'Last Project Report comment date/time'
def titleAuthor = 'Author :'
def titleDateTime = 'Date/Time :'
// Get custom fields properties
def customFields = get("/rest/api/2/field")
.asObject(List)
.body
.findAll { (it as Map).custom } as List<Map>
// Get ProjectReport comment custom field id
def ProjectReportCommentCfId = customFields.find { it.name == ProjectReportCommentFieldName }?.id
// Get last issue comment author custom field id
def lastProjectReportCommentAuthorCfId = customFields.find { it.name == lastProjectReportCommentAuthorFieldName }?.id
// Get last issue comment date/time custom field id
def lastProjectReportCommentDateTimeCfId = customFields.find { it.name == lastProjectReportCommentDateTimeFieldName }?.id
// Updates the issue with the created comment body
put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(ProjectReportCommentCfId): comment.body
]
])
.asString()
// Updates the issue with the created comment author
put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(lastProjectReportCommentAuthorCfId): comment.author
]
])
.asString()
// Updates the issue with the created comment date/time
put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(lastProjectReportCommentDateTimeCfId): comment.created
]
])
.asString()
I tried stuff like this but that did not work:
// Updates the issue with the created comment body
put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(ProjectReportCommentCfId): comment.body + " " + comment.author + " " + comment.created
]
])
.asString()
Any ideas? Thank you for your insight!