Hello,
I'm writing a Jira plugin which stores certain information (that I obtained elsewhere) about an issue as an ActiveObject and displays it through a template attached to the issue.
I'm not saving anything in actual CustomFields because there would be too many (I would need about 25, which is why I went with the ActiveObject solution), so there are no change log entries within the issue when the ActiveObject updates. Since the information still belongs to the Issue, I would like to see a history of changes of that info as well.
I'm new to the Jira plugin development and haven't been able to figure it out, since all the solutions I've seen assume that there is a CustomField where the changes happen.
In pseudo code, I would like to do something simple like this:
ChangeItem changeItem = new ChangeItem(fieldName, oldValue, newValue);
someService.addHistoryEntry(issue, changeItem);
"fieldName" has nothing to do with the actual fields of the issue. It's just some String I want displayed. Is this possible or does a history entry always have to have a reference to a certain field? So far I've done this:
DefaultIssueChangeHolder issueChangeHolder = new DefaultIssueChangeHolder();
ChangeItemBean changeItemBean =
new ChangeItemBean(ChangeItemBean.CUSTOM_FIELD, "some random label", "from", "to");
issueChangeHolder.addChangeItem(changeItemBean);
But I don't know what to do with the IssueChangesHolder now, since I have no CustomFields. Do I need to create a fake CustomField that's never displayed and use that for my change log entries? Will I be able to randomly change the label and will that break anything?
Thanks!
Hi @Robert Hansen
I had the same Problem and found here a solution: https://community.atlassian.com/t5/Jira-questions/How-to-update-issue-history-using-java-api/qaq-p/1388695#M474842
In short, what you need is this line:
ChangeLogUtils.createChangeGroup(currentUser, issue, issue, issueChangeHolder.getChangeItems(), false);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.