It's all about the answers!

Ask a question

Is it possible to access "Time Tracking" sheet using Plain java API to set values?


Karthik Krishnan (8594103153) | asked Jun 25 '14, 9:39 a.m.
Is it possible to set values to "Time tracking" in Task via Plan Java API?
Time tracking
If so can someone point to the correct API?

Thanks




Accepted answer


permanent link
Ralph Schoon (61.6k33643) | answered Mar 31 '15, 10:42 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
For anyone who searches for example, I created example code to access and modify the time tracking data for work items and published in this post: https://rsjazz.wordpress.com/2015/03/31/the-work-item-time-tracking-api/
Karthik Krishnan selected this answer as the correct answer

One other answer



permanent link
Arne Bister (2.6k12732) | answered Jun 25 '14, 11:37 a.m.
JAZZ DEVELOPER
Karthik,

I doubt it would be in the Plain Java API. If you load the published RTC SDK however and Java Search for TimeSheet, the com.ibm.team.rtc.reports.service.test has a class BaseRTCReportTest.
There is a method: createTimesheetEntry that has sample code.  I would have guessed that some parts of it probably rely on internal API but so far I have not found anything. Seems to be all legit parts of the published RTC SDK.

Core method:
with: IWorkItemService workItemService
ITimeSheetEntry entry = workItemService.createTimeSheetEntry(projectArea);


If this is helpful please mark this answer accepted.
Thanks,
Arne

Comments
Sanjeev Kulkarni commented Jun 26 '14, 11:45 a.m. | edited Jun 26 '14, 11:47 a.m.

Hello Arne,
Thanks for the hint, we tried with below code snippet but it's not working.
 
ITimeSheetEntry entry = workItemClient. createTimeSheetEntry(projectArea);       
entry.setTimeSpent(new Duration(1000L6060));
entry.setTimeCodeId("timecode.literal.l2"); entry.setStartDate(Timestamp.valueOf("2014-06-20 20:30:00"));
entry.setCreator(workItem.getOwner());           

IWorkItemReferences copyReferences = workItemWorkingCopyManager.getReferences();
IItemReference timesheetRef = IReferenceFactory.INSTANCE.createReferenceToItem(entry);
copyReferences.add(WorkItemEndPoints.WORK_TIME, timesheetRef);
workItemWorkingCopyManager.getDependentItems().add(entry);

Exception occurs at the last line [workItemWorkingCopyManager.getDependentItems().add(entry);], We even tried skipping this (no exceptions but value is not saved)

com.ibm.team.repository.common.validation.PropertyConstraintException: Validation errors for item: type = TimeSheetEntry, itemId = [UUID _flFMcP0TEeOc05tOqOHMlw]

Your answer


Register or to post your answer.