Using Custom Operation Advisor(custom precondition) to check if workitem's time tracking could be saved.
Imagine following case for RTC 3.0.1:
A user enters his progress in hours for a particular work item in the time tracking tab.
I should prohibit him to save this data if he enters it in some invalid time periods (i.e. before 01.01.2013).
The idea was to develop a plugin that would implement custom precondition for the save operation. This plugin could have asked an external service for invalid time periods.
The problem: I don't know how could my plugin get the data entered by a user in the time tracking tab.
A user enters his progress in hours for a particular work item in the time tracking tab.
I should prohibit him to save this data if he enters it in some invalid time periods (i.e. before 01.01.2013).
The idea was to develop a plugin that would implement custom precondition for the save operation. This plugin could have asked an external service for invalid time periods.
The problem: I don't know how could my plugin get the data entered by a user in the time tracking tab.
Accepted answer
I searched the API for ITimeSheetEntry and figured it is managed as a reference. See the client code below.
So you would look into the new references of the new state.
ITimeSheetEntry entry= workItemClient.createTimeSheetEntry(fgProjectArea); entry.setStartDate(now); entry.setTimeSpent(twoHours); entry.setTimeCodeId(timeCodeId); entry.setTimeCode(timeCodeLabel); entry.setWorkType(workType); references.add(WorkItemEndPoints.WORK_TIME, IReferenceFactory.INSTANCE.createReferenceToItem(entry)); workingCopy.getDependentItems().add(entry);