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 (8825118163) | 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?


Accepted answer

permanent link
Ralph Schoon (63.1k33646) | answered Mar 31 '15, 10:42 a.m.
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:
Karthik Krishnan selected this answer as the correct answer

One other answer

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

I doubt it would be in the Plain Java API. If you load the published RTC SDK however and Java Search for TimeSheet, the 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.

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"));

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

Exception occurs at the last line [workItemWorkingCopyManager.getDependentItems().add(entry);], We even tried skipping this (no exceptions but value is not saved) Validation errors for item: type = TimeSheetEntry, itemId = [UUID _flFMcP0TEeOc05tOqOHMlw]

Your answer

Register or to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.