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
hi
I want show first worklog date (base on start date, not create date) in a date field.
this is my code that use worklog list and get first element of list. but this is base on work log created date, not base on worklog start date.
WorklogManager worklogManager = ComponentAccessor.getWorklogManager()
List<Worklog> worklogList = worklogManager.getByIssue(issue)
Worklog firstWorklog = worklogList[0]
return firstWorklog.getStartDate()
this code return start date of first created worklog but I want to show start date of first worklog base on start date. in other words I need a worklog list that sort base on worklog start date but worklogManager.getByIssue(issue) return a worklog list that sort base on worklog create date.
any help for this ?!
thanks
thank for your help
must I import any thing for these functions ?!
ok, I solved problem with this code :
WorklogManager worklogManager = ComponentAccessor.getWorklogManager()
List<Worklog> worklogsList = worklogManager.getByIssue(issue)
Worklog firstWorklog
for (item in worklogsList){
if (firstWorklog == null){
firstWorklog == item
}
if (item.getStartDate().getTime() < firstWorklog.getStartDate().getTime()){
firstWorklog = item
}
}
return firstWorklog.getStartDate()
The code has an error with == instead of =.
Here you are the correct code:
WorklogManager worklogManager = ComponentAccessor.getWorklogManager()
List<Worklog> worklogsList = worklogManager.getByIssue(issue)
Worklog firstWorklog
for (item in worklogsList){
if (firstWorklog == null){
firstWorklog = item
}
if (item.getStartDate().getTime() < firstWorklog.getStartDate().getTime()){
firstWorklog = item
}
}
return firstWorklog.getStartDate()