How to get estimate of the work item using plain Java API?
Hi all,
I need to fetch "Estimate" of the workitem using plain Java API, I wrote following code:
IWorkItemCommon workItemCommon = (IWorkItemCommon ) teamRepository.getClientLibrary(IWorkItemCommon.class);
IAttribute built_in_duration = workItemCommon.findAttribute(DataRepository.getInstance().getProjectArea(), IWorkItem.DURATION_PROPERTY, monitor);
Object value = workItem.getValue(built_in_duration);
but I received following exception:
java.lang.IllegalStateException: Attempting to get unset feature: Duration
Please help me on this point
One answer
You have to check if the item has a value, before you get a value, or handle the exception.
if (!workItem.hasAttribute(attribute)) {
}
The estimate is calculated based on settings in the project area process, based on the attribute ID's
Estimate ID: duration ValueType: duration
Corrected Estimate ID: correctedEstimate ValueType: duration
Time Spent(Time Remaining) ID: timeSpent ValueType: duration
This is for the agile process templates.
Comments
Thanks @Ralph Schoon thanks for your quick reply. I have estimate field in my workitem and some "xx" estimate is assigned for the workitem, still I get the mentioned exception.
Sorry to hear that, I have used this code and it worked for me. E.g.
In a server extension: https://rsjazz.wordpress.com/2012/07/31/rtc-update-parent-duration-estimation-and-effort-participant/
There is also code in the WCL for this and it works for me. Check for has attribute and if there is one get the value. Otherwise assume it is not set.
Also https://rsjazz.wordpress.com/2013/01/02/working-with-work-item-attributes/ shows how to.
Duration is a Long in milliseconds. There is no useful information in your comment to act upon. You should be able to easily debug this.