It's all about the answers!

Ask a question

How to get estimate of the work item using plain Java API?


Andrew Ciaz (59160) | asked May 11 '20, 4:22 a.m.

 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



permanent link
Ralph Schoon (63.1k33645) | answered May 11 '20, 7:31 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER

 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
Andrew Ciaz commented May 11 '20, 8:17 a.m.

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.



Ralph Schoon commented May 11 '20, 9:56 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER


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.


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.

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.