How do I save a value into a custom field in JIRA programmatically?

后端 未结 4 1240
粉色の甜心
粉色の甜心 2020-12-30 06:24

I\'ve spent days trying to find out how to save or update a value into a CustomField programmatically and finally found out how it\'s done. So I\'ll make this a question an

4条回答
  •  渐次进展
    2020-12-30 07:01

    Here is how I do it (for a custom field I programmatically store a random UUID in):

    CustomField cfHash = customFieldManager.getCustomFieldObjectByName(...);
    IssueChangeHolder changeHolder = new DefaultIssueChangeHolder();
    try {
        Object newHashValue = java.util.UUID.randomUUID().toString();
        Object oldHashValue = issue.getCustomFieldValue(cfHash);
    
        issue.setCustomFieldValue(cfHash, newHashValue);
        cfHash.updateValue(null, issue, new ModifiedValue(oldHashValue, newHashValue), changeHolder);
    ...
    

    More or less the same as you but with another way to get the ModifiedValue-Object.

提交回复
热议问题