I want to update an existing JIRA Issue and set a new value for the assignee. Up till now I have managed to update issue status with the following:
issueManager.updateIssue(user, issue, EventDispatchOption.ISSUE_ASSIGNED, false);
I also managed to update the description via IssueInputParameters, however using the same method the Assignee is never assigned.
issueInputParameters.setAssigneeId(userManager.getUserByName("admin-daniel").getKey()) .setDescription("I am the issue description.4");
The Description is set however the Assignee remains unassigned via this method. Any ideas as to why this may be happening?
Community moderators have prevented the ability to post new answers.
IssueService issueService = ComponentAccessor.getIssueService();
IssueInputParameters issueInputParameters = issueService.newIssueInputParameters();
LOG.error(
"Updating Issue."
);
//Setting Issue Input Parameters
issueInputParameters.setAssigneeId(userManager.getUserByName(
"admin-daniel"
).getName());
//Validating Update
IssueService.validateAssign(userManager.getUserByName(
"admin-daniel"
),currentIssue.getId(),userManager.getUserByName(
"admin-daniel"
).getName()
);
Hi,
Try use issueInputParameters.setAssigneeId(userManager.getUserByName(
"admin-daniel"
).getName())
setAssigneeId() method takes username as parameter:
issueInputParameters.setAssigneeId(user.getName());
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi J.Fawkes,
Thanks for your answer. However the user remained unassigned, as per the image below:
image2016-4-22 17:47:34.png
On the other hand, the description was set. The code is as per below.
IssueService issueService = ComponentAccessor.getIssueService(); IssueInputParameters issueInputParameters = issueService.newIssueInputParameters(); LOG.error("Updating Issue."); //Setting Issue Input Parameters issueInputParameters.setAssigneeId(userManager.getUserByName("admin-daniel").getName()) .setDescription("User Name: " + userManager.getUserByName("admin-daniel").getName()); //Validating Update IssueService.UpdateValidationResult updateValidationResult = issueService.validateUpdate(user, issue.getId(), issueInputParameters); if(updateValidationResult.isValid()) { IssueResult updateResult = issueService.update(user, updateValidationResult); LOG.error("Update Result Done without error. Assignee is " + updateResult.getIssue().getAssignee().getDisplayName()); }else{ LOG.error("Update Validation Result not Valid."); }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I ended up solving the problem by scrapping IssueInputParameters in favor of the following:
MutableIssue mutableIssue = ComponentAccessor.getIssueManager().getIssueByCurrentKey(issue.getKey()); mutableIssue.setAssignee(user); IssueManager issueManager = ComponentAccessor.getIssueManager(); issueManager.updateIssue(user, mutableIssue,EventDispatchOption.ISSUE_ASSIGNED, true);
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, @Daniel Micallef, even I am facing the same problem - I tried your solution but still its not setting the assignee. Is there anything more to the above code , by any chance?
Update : I see the assignee being updated in issue history but NOT on the screen. Is there anything I am missing?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Yagnesh Bhat, this was done using JIRA 6.3;
I think you should check if any changes were made for your version of JIRA, maybe the type of user (ApplicationUser or simply User). Also make sure that you are using MutableIssue.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for the update Daniel, its now working
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Yagnesh Bhat , Can i have the detailed code used for updating an assignee automatically in an issue using ScriptRunner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@Raj , its been quite a while I got that working, however, I just saw the answer provided by @Ahm CHA below this one - I think that should work. Basically you set the assignee id through issueinput parameters :
And then validate the assign transition using the issue service method:
For more info about using the issue service and how it works, please refer to this awesome documentation by Atlassian:
https://developer.atlassian.com/server/jira/platform/performing-issue-operations/
Hope this helps.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.