You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
The Atlassian Community can help you and your team get more value out of Atlassian products and practices.
Hi,
For some reason (potential workaround for issue described here ) I would like to be able to change the "Time Logged" field.
I have been able to change the "Time Logged" field only via the MutableIssue.store() method, but neither by using the IssueManager.upateIssue() method nor the IssueService.update() method.
Obviously I do not want to use the MutableIssue.store() method because it has been deprecated.
Any hint?
MutableIssue.store() - Works
IssueManager issueManager = ComponentAccessor.getIssueManager() MutableIssue issue = issueManager.getIssueObject("TASKTEST-315") ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); Long val = 3600 * 4 issue.setTimeSpent(val) issue.store()
IssueService.update() - Does not work
IssueManager issueManager = ComponentAccessor.getIssueManager() MutableIssue issue = issueManager.getIssueObject("TASKTEST-315") ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); IssueService issueService = ComponentAccessor.getIssueService() Long val = 3600 * 4 IssueInputParameters inputParameters = issueService.newIssueInputParameters() inputParameters.setTimeSpent((Long)(val/60)) IssueService.UpdateValidationResult validationResult = issueService.validateUpdate(user,issue.id,inputParameters) issueService.update(user, validationResult)
IssueManger.updateIssue() - Does not work
IssueManager issueManager = ComponentAccessor.getIssueManager() MutableIssue issue = issueManager.getIssueObject("TASKTEST-315") ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser(); Long val = 3600 * 4 issue.setTimeSpent(val) issueManager.updateIssue(user,issue,EventDispatchOption.ISSUE_UPDATED,false)
I usually use IssueManager.updateIssue(), but it is better to use this one because it is compatible JIRA6 and 7:
ComponentAccessor.getIssueManager().updateIssue( ComponentAccessor.getJiraAuthenticationContext().getUser() , issue , UpdateIssueRequest.builder().eventDispatchOption(EventDispatchOption.ISSUE_UPDATED).sendMail(false).build() )
Also check that you have permission to log time?
You could get more information about errors into atlassian-jira.log.
Hi Vasiliy, thank you for your answer. I tried the code that you suggested, but it did no work. As per my original post, the only method that I have found being successful so far is MutableIssue.store(). The code that you suggested works fine if I want to change other fields (e.g. summary), but it does not work when I want to change the "TimeSpent" (TimeLogged) field.
I have checked and verified that I have the permissions to log time.
Neither atlassian-jira.log nor catalina.out report any error when I execute your code.
Thanks.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Could you check as admin that you have a permission to log time for issue?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi. Same problem and same solution (use deprecated issue.store() methos)
Any news?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You should use this instead of issue.store():
ComponentAccessor.getIssueManager().updateIssue( ComponentAccessor.getJiraAuthenticationContext().getUser() , issue , UpdateIssueRequest.builder().eventDispatchOption(EventDispatchOption.ISSUE_UPDATED).sendMail(false).build() )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Was there any solution? I am having the same problem with "Time Logged" changing. issue.store() works fine, but it's depricated.
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.