ScriptRunner How to build HistoryMetadata for an issue ChangeGroup ?

Yves Martin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 31, 2018

 Hello

Many examples here refer to custom field modification sequence as

def changeHolder = new DefaultIssueChangeHolder()
customField.updateValue(null, issue,
new ModifiedValue(issue.getCustomFieldValue(customField), newValue), changeHolder)
issueManager.updateIssue(user, issue, EventDispatchOption.DO_NOT_DISPATCH, false)

Then JIRA issue lacks a "History" block to track such "change items". I guess "change group" has been created without any "history metadata".

So I try to move to UpdateIssueRequest builder API:

def historyParticipant = HistoryMetadataParticipant.builder(user.getUsername(), "user?").build()
def historyMetadata = HistoryMetadata.builder("type?")
.actor(historyParticipant).activityDescription("Migration labels").build()
def updateIssueRequest = UpdateIssueRequest.builder().historyMetadata(historyMetadata)
.eventDispatchOption(EventDispatchOption.DO_NOT_DISPATCH).sendMail(false).build()
issueManager.updateIssue(user, issue, updateIssueRequest)

But I have found no effective example in API how to properly:

- build HistoryMetadataParticipant which requires an ID and a Type - what should they be?

- build HistoryMetadata which requires also a Type - what are possible values?

And of course, I fear to break my JIRA instance after any trial with stupid types or ids...

May you help me to find out the right way to do it?

Thank you in advance for your help

Yves

1 answer

1 accepted

0 votes
Answer accepted
Yves Martin
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 6, 2018

According to https://community.atlassian.com/t5/Agile-articles/Three-ways-to-update-an-issue-in-Jira-Java-Api/ba-p/736585

CustomField.updateValue will not create change history. So I had to switch to IssueService.update method.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events