Are you in the loop? Keep up with the latest by making sure you're subscribed to Community Announcements. Just click Watch and select Articles.

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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Unable to update Time Spent value through IssueService

Edited

Hello everyone, 

I could use some help with my script listener implementation. I've also posted same question in to the developer community, but didn't got any answers, so I'm trying again this route. 

I’m trying to create a listener, that sums up Original Estimate, Remaining Estimate and Time Spent values from linked issues to a Feature issue. Everything else seems to be working as expected, but for some reason timeSpent value cannot be updated through IssueService or IssueManager. When updating the value through mutableIssue and using deprecated store() method to save the value, it seems to be working. However, I would like to use the IssueService and its update() method.

Code examples to explain my problem:

// EXAMPLE 1:
def param = issueService.newIssueInputParameters()
param.setSkipScreenCheck(true) 			// No effect
param.setTimeSpent((Long) 1800)		
param.setOriginalAndRemainingEstimate(secondsToTimeString(10800), secondsToTimeString(7200))

log.warn(param.getTimeSpent())		       // Returns 1800 (correct)
log.warn(param.getOriginalEstimate()) 	       // Returns 10800 (correct)

def result = issueService.validateUpdate(user, mutableIssue.id, param)
log.warn(result.isValid()) 		       // Returns true
def updatedIssue
if (result.isValid()) {
    updatedIssue = issueService.update(user, result)
    indexManager.reIndex(parentIssue)
}

log.warn(updatedIssue.isValid()) 		        // Returns true
log.warn(updatedIssue.getIssue().getTimeSpent())	// Returns 4000 (incorrect)
issueIndexingService.reIndex(mutableIssue)

//EXAMPLE 2:
mutableIssue.setTimeSpent((Long) 3600)
mutableIssue.setEstimate((Long) 7200)
log.warn(mutableIssue.getTimeSpent()) 		// Returns 3600
log.warn(issueManager.isEditable(mutableIssue)) // Returns true

// mutableIssue.store() // This updates both values and works as expected

Issue updatedIssue = issueManager.updateIssue( 	
    user, 
    mutableIssue,      UpdateIssueRequest.builder().eventDispatchOption(EventDispatchOption.ISSUE_UPDATED).sendMail(false).build()
)                             // This updates only the estimate value, why?

log.warn(updatedIssue.getTimeSpent()) 		// Returns 3600 (correct)
issueIndexingService.reIndex(mutableIssue)

Log work and Time Tracking fields are present on the project screens and I’ve also tried, without success, to skip screen check with IssueParameters setSkipScreenCheck() method. Script’s user also has permissions to edit and log work on issue. What am I doing wrong? 

Thank you in advance!

Br
Janne

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events