We're using this script to set up a custom field called Last comment (script field):
/**
* Field name: Last Comment
* Template: Text Field (multi-line)
*
* Description:
* Returns the last comment on an issue.
*
*/
import com.atlassian.jira.component.ComponentAccessor
// get the latest comment
def commentManager = ComponentAccessor.getCommentManager()
def comment = commentManager.getLastComment(issue)
// check to see if comments exist - return comment body if so
if (comment != null) {
return comment.body
}
return null
This returns the last comment, whether it's internal or external.
We need this script to return ONLY the last EXTERNAL comment.
I found this link; https://community.atlassian.com/t5/Jira-Service-Management/Scriptrunner-Latest-public-comment-in-custom-email/qaq-p/1406868
But we get an error:
groovy.lang.MissingPropertyException: No such property: transientVars for class: Script8473 at Script8473.run(Script8473.groovy:7)
How can we set transientVars as a script field?