It's all about the answers!

Ask a question

RTC 5.0 JavaAPI How setValue TimeSpent ?


HIROAKI JOSAKO (47427) | asked May 12 '16, 5:07 a.m.
It has created a process of acquiring the attribute object of Times pent.
But, the object will become null.


IAttribute attribute = workItemClient.findAttribute(IWorkitem.getProjectArea(), "internalTimeSpent" , null)
getWorkItem().setValue(attribute, timespentvalue.longValue());

[result]
attribute = null

Project area variable is to get the correct information.
IWorkitem.getProjectArea()

thanks regard!!

2 answers



permanent link
Michele Pegoraro (1.8k14118103) | answered May 12 '16, 5:32 a.m.
Hi, I don't know where you find that time spent field id, but I think you should use WorkItemAttributes.TIME_SPENT as field id to get the time spent.

Michele.

Comments
HIROAKI JOSAKO commented May 12 '16, 5:36 a.m.

Hi
Michele

I imitated the articles that have been published in IBM, but failed.
ID of TimeSpent is given on the JazzForum and PlainJavaAPI reference.

example:
http://www.ibm.com/developerworks/cn/rational/1308_wangjian_pojortcworkitem/


Michele Pegoraro commented May 12 '16, 5:45 a.m.

I don't think I ever seen this article before (and I'm not seeing the "internalTimeSpent" id either), anyway I generally use the attribute I wrote (I prefer use class defined constants for internal field ) and it works so I suggest you to give it a try.

The attribute id will work for both get and set, so if in doubt I always test the get before the set, to be sure of the id.


HIROAKI JOSAKO commented May 12 '16, 10:54 p.m.

I'm sorry.
This example is bad.

get Attribute ID:
timeSheet.TIME_SPENT_PROPERTY;  //<-"internaltimespent"

timeSheet is ITimeSheetEntry
override IWorkItem

Is there a way to get the ID of TimeSpent?


Michele Pegoraro commented May 16 '16, 4:36 a.m.

As I was saying: the id to be used in the .getValue method is the one that you can obtain from this property: com.ibm.team.workitem.api.common.WorkItemAttributes.TIME_SPENT

Michele.


HIROAKI JOSAKO commented May 23 '16, 9:19 p.m.

understood.
What is needed in the process, pointing to the attribute ID "timespent" ConstValue
There was no constant property in the imported class.
I decided to write directly "timespent".

IAttribute attribute = workItemClient.findAttribute(IWorkitem.getProjectArea(), "timespent" , null)


Michele Pegoraro commented May 24 '16, 5:09 a.m.

Which version are you using?

Because in 5.0.2 I see this in the class I mentioned (and by experience I would not say that is something that change often):

public static final String TIME_SPENT= "timeSpent"; //$NON-NLS-1$
By the way you can use "timeSpent" hard coded, I only prefer to use the api constant, as I think it is safer.

showing 5 of 6 show 1 more comments

permanent link
Ralph Schoon (63.1k33646) | answered May 24 '16, 5:45 a.m.
FORUM ADMINISTRATOR / FORUM MODERATOR / JAZZ DEVELOPER
The work item command line https://rsjazz.wordpress.com/2015/11/03/a-rtc-workitem-command-line-version-3-0/ reads and sets time spent. The downloadable code is attached. It should be easy enough to look up the code.

There is no constant on IWorkItem if you look up the attribute ID in the Web Admin UI, it is "timeSpent".

I set it with a new Long(String);

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.