I am trying to see the last value for a specific custom field with the code below but I m getting an error. Could someone advise how to resolve this?
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager;
import com.atlassian.jira.issue.history.ChangeItemBean;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
//For test
Issue issue = ComponentAccessor.getIssueManager().getIssueByKeyIgnoreCase("EPIC-10");
String fieldName = 'Who'
def ChangeHistoryManager= ComponentAccessor.getChangeHistoryManager();
List<ChangeItemBean> changeItems
changeItems = ChangeHistoryManager.getChangeItemsForField(issue, fieldName)
if (changeItems.size()>0) {
return changeItems.get(0).getFrom()
}
Hello,
What is the error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
It is a static compilation error. Just run this script. It should work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Alexey Matveev, thank you. It is returning null despite size returning 2 with the expected value in getCreated(), but I can't seem to get the value of the From or To string...
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager;
import com.atlassian.jira.issue.history.ChangeItemBean;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
//For test
Issue issue = ComponentAccessor.getIssueManager().getIssueByKeyIgnoreCase("EPIC-10");
String fieldName = 'Who'
def ChangeHistoryManager= ComponentAccessor.getChangeHistoryManager();
List<ChangeItemBean> changeItems
changeItems = ChangeHistoryManager.getChangeItemsForField(issue, fieldName)
if (changeItems.size()>0) {
return changeItems.get(changeItems.size()-1).getFrom()
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Try like this:
import com.atlassian.jira.issue.changehistory.ChangeHistoryManager;
import com.atlassian.jira.issue.history.ChangeItemBean;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
//For test
Issue issue = ComponentAccessor.getIssueManager().getIssueByKeyIgnoreCase("EPIC-10");
String fieldName = 'Who'
def ChangeHistoryManager= ComponentAccessor.getChangeHistoryManager();
List<ChangeItemBean> changeItems
changeItems = ChangeHistoryManager.getChangeItemsForField(issue, fieldName)
if (changeItems.size()>0) {
return changeItems.get(changeItems.size()-1).getFromString()
}
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.
If my answer helped you, kindly mark it as accepted. In this case other users with a similar question will be able to find this answer.
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.
Hello,
It is a static compilation error. Just run this script. It should work.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.