Hi all,
I am trying to get the last comment and check if that contains a string. If string found transition the issue.
Trying to do this via scriptrunner. Have created the below script and added it to the listener. But am getting into the "null" pointer exception.
Interestingly, when am returning "comment.body" this is working fine but when storing in a string, it is not getting stored and not able to perform any string operations on it.
Example last comment on JIRA ticket: Ram has updated the status of a ticket linked to this issue from [Open] to [Resolved]
Based on this comment ticket will need to be moved to Resolved (transition id :11)
Your quick help is much appreciated.
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.component.ComponentAccessor
def issueService = ComponentAccessor.getIssueService()
IssueManager im = ComponentAccessor.getIssueManager();
MutableIssue issue = im.getIssueObject("ITP-26")
def commentManager = ComponentAccessor.getCommentManager()
def comment = commentManager.getLastComment (issue)
//return comment.body is printing the last comment properly
// if i use println(comment.body) - getting null value.
String lastcomment = comment.getBody()
// this is the last comment on the ticket: Ram has updated the status of a ticket linked to this issue from [Open] to [Resolved]
lastcomment.contains("has updated the status of a ticket linked to this issue from [Open] to [Resolved]")
// is returning false
// when trying to put in if condition getting null
// if(lastcomment.contains("has updated the status of a ticket linked to this issue from [Open] to [Resolved]"))
Regards,
Ram