Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Why this way to set description not work ?

Albert Cameron October 14, 2021

My colleague wanted to set description of issue. He tried this way . But he said it did not work. 


public static void setDescription(Issue issue, String message) {

ComponentAccessor.getIssueManager().getIssueObject(issue.getId()).setDescription(message);
}

 He argued to do it that way because not every issue may be a MutableIssue. That's why he did not want to do :

((MutableIssue)issue).setDescription(message);

But I said every issue you get from Jira will be mutable, because every issue has fields you can edit. But that is only my opinion. 

1 answer

0 votes
Nic Brough -Adaptavist-
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.
October 14, 2021

Your colleague does not understand the internals of Jira.  An issue object is a representation of the current issue, it is not an editable issue object like the mutableissue is.

You probably shouldn't be trying to set the description this way either, there's several things your code needs to do to the issue alongside setting a field.  It's better to use the issueService to do it, as it'll handle all of it for you and trap and return errors properly.

Albert Cameron October 15, 2021

Originally it is a issue of type DocumentIssueImpl .

That means it is not a MutuableIssue.

To set the description I now tried:

ApplicationUser user = ComponentAccessor.getUserManager().getUserByName("Admin");
IssueService.IssueResult issue1 = ComponentAccessor.getIssueService().getIssue(user, issue.getId());
issue1.getIssue().setDescription("Some description");

 But again it was not working !

Suggest an answer

Log in or Sign up to answer