Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to update issue in custom script listener?

Dipenkumar Patel March 31, 2015

I am trying to update and issue after changing assignee of the Issue with JIRA 6.3.13 version.

But its throwing below exception. Tried multiple things but getting same error.

Could you please let me know how to update the issue and reindex it?

No signature of method: com.atlassian.jira.issue.managers.DefaultIssueManager.updateIssue() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser, com.atlassian.jira.issue.IssueImpl, com.atlassian.jira.event.type.EventDispatchOption$EventDispatchOptionImpl, java.lang.Boolean) values: [patdi004(patdi004), IN-35, com.atlassian.jira.event.type.EventDispatchOption$EventDispatchOptionImpl@5193c02e, ...]

Possible solutions: updateIssue(com.atlassian.crowd.embedded.api.User, com.atlassian.jira.issue.MutableIssue, com.atlassian.jira.event.type.EventDispatchOption, boolean), updateIssue(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.issue.MutableIssue, com.atlassian.jira.issue.UpdateIssueRequest)

 

 

 

Here is my code snippet:

ApplicationUser appUser = ComponentAccessor.getUserUtil().getUserByName("XYZ")
User user = appUser.getDirectoryUser()
issue.setAssignee(user)
//ComponentAccessor.getComponent(IssueManager.class).updateIssue(ComponentAccessor.jiraAuthenticationContext?.user,issue, EventDispatchOption.DO_NOT_DISPATCH, false)
ComponentAccessor.getComponent(IssueManager.class).updateIssue((ApplicationUser)ComponentAccessor.jiraAuthenticationContext?.user,issue, UpdateIssueRequest.builder().build())
ComponentAccessor.getIssueIndexManager().reIndex(issue)

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
Volodymyr Krupach
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.
March 31, 2015
Dipenkumar Patel April 1, 2015

Thanks Volodymyr for your reply. As you suggested I implemented my code but somehow Issue is not getting update evernthough my log message says updated successfully. I tried it 2 different ways but no success. def ApplicationUser user = ComponentAccessor.userUtil.getUserByName("JIRASupport") log.warn("Current Assignee: " + issue.getAssigneeUser().getName()) issueInputParameters.with { //setAssigneeId(user.getName()) issue.setAssignee(ApplicationUsers.toDirectoryUser(user)) } log.warn("New Assignee : " + issue.getAssigneeId() +" UserName: " + issue.getAssignee().getName()) def IssueService.UpdateValidationResult validationResult = issueService.validateUpdate(ApplicationUsers.toDirectoryUser(user),issue.id,issueInputParameters) if(validationResult.isValid()){ issueService.update(ApplicationUsers.toDirectoryUser(user),validationResult) ComponentAccessor.getIssueIndexManager().reIndex(issue) log.warn("${validationResult.issue.key} has been updated successfully") }else{ log.warn(validationResult.errorCollection) } Log Message: /secure/WorkflowUIDispatcher.jspa [com.custom.IntakeListener] Not assigned to JIRA Support /secure/WorkflowUIDispatcher.jspa [com.custom.IntakeListener] ******** Updating ********************************* /secure/WorkflowUIDispatcher.jspa [com.custom.IntakeListener] Current Assignee: patdi004 /secure/WorkflowUIDispatcher.jspa [com.custom.IntakeListener] Assignee Changed /secure/WorkflowUIDispatcher.jspa [com.custom.IntakeListener] New Assignee : jirasupport UserName: JIRASupport /secure/WorkflowUIDispatcher.jspa [com.custom.IntakeListener] IN-35 has been updated successfully AM I doing anything wrong here? Please help.

Volodymyr Krupach
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.
April 1, 2015

Hi Dipenkumar! I have similar code that in Java that creates issues via issueService.create and it works fine. BTW you should not invoke ComponentAccessor.getIssueIndexManager().reIndex(issue) since issueService.udpate already does re-index. Only guess is that your index file is broken so please try to reindex through JIRA admin and then run the code.

Dipenkumar Patel April 2, 2015

After re-indexing also I am seeing same behavior as earlier. Log says updated successfully but it doesn't reflect actually. ComponentAccessor.getIssueIndexManager().reIndex(issue) added as its not working but initially wrote it without this line. What else should I do?

Volodymyr Krupach
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.
April 2, 2015

As I said, issueService.create works fine for me. And I have no idea why issueService.update does not work for you.

Volodymyr Krupach
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.
April 2, 2015

Sorry :-(

Dipenkumar Patel April 2, 2015

Resolved the issue by adding these line in my code. issueInputParam.setRetainExistingValuesWhenParameterNotProvided(true,true); issueInputParam.setApplyDefaultValuesWhenParameterNotProvided(false); issueInputParam.setSkipScreenCheck(true); Now its working fine. Thanks Volodymyr for your initial help.

Volodymyr Krupach
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.
April 2, 2015

Glad that you resolve this and thank you for sharing! I am sure that with issueService.update I would hit the same problem :-)

TAGS
AUG Leaders

Atlassian Community Events