Hi,
I'm looking for how to implement the last issue comment scripted field, with the example from the library. Additionally I would want to implement the same kind of scripted fields for the last issue comment author and last issue comment date/time.
These fields are to appear in filter results.
Anyone can share the screenshots for the setup on Jira cloud with some explanation and the script code?
Thanks!
So with help from the scriptrunner support team I got it to work.
It starts with creating the appropriate custom fields:
I created
Then in Scriptrunner I created this listener which listened on the Comment Created and Comment Updated events.
The script itself then looked like this:
//Last update by Ward Schwillens at 16/11/2022 18.27
final lastIssueCommentFieldName = 'Last issue comment'
final lastIssueCommentAuthorFieldName = 'Last issue comment author'
final lastIssueCommentDateTimeFieldName = 'Last issue comment 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 last issue comment custom field id
def lastIssueCommentCfId = customFields.find { it.name == lastIssueCommentFieldName }?.id
// Updates the issue with the created comment body
put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(lastIssueCommentCfId): comment.body
]
])
.asString()
// Get last issue comment author custom field id
def lastIssueCommentAuthorCfId = customFields.find { it.name == lastIssueCommentAuthorFieldName }?.id
// Updates the issue with the created comment author
put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(lastIssueCommentAuthorCfId): comment.author
]
])
.asString()
// Get last issue comment date/time custom field id
def lastIssueCommentDateTimeCfId = customFields.find { it.name == lastIssueCommentDateTimeFieldName }?.id
// Updates the issue with the created comment date/time
put("/rest/api/2/issue/${issue.key}")
.header("Content-Type", "application/json")
.body([
fields:[
(lastIssueCommentDateTimeCfId): comment.created
]
])
.asString()
And after having created or updated an issue comment you can have the fields in a filter result.
Hi @Ward Schwillens_ Schwillie
What do you mean by "last issue comment scripted field"?
And to which library of examples are you referring?
If you are trying to use an automation rule to access this information, based upon the issue commented trigger, please look here for the smart values to use: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--issue.comments--
Kind regards,
Bill
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.