It's all about the answers!

Ask a question

RTC API: how to set a work item modification date to an arbitrary one?

Jerome De (2825) | asked Jun 26 '17, 9:04 a.m.
edited Jun 26 '17, 11:34 a.m.

Context: copying work item histories from one repository to another.
When reading a workitem state, I can read when it has been saved to the server:

IWorkItem wi;
Date d;
d = wi.modified();


It's all good, I can read when a work item has been updated.

Now, I would like to write a new work item or update a work item and specify a timestamp for the update itself, a different one than the one automatically set by the server. How can I override the default timestamp put by the server and set an arbitrary modification date (my goal is to reflect the original history from the source repository)? Thanks!

EDIT: same thing for the user: I would like to change not only the timestamp of a change, but also the user who did it.

Accepted answer

permanent link
Geoffrey Clemm (30.1k33035) | answered Jun 26 '17, 5:06 p.m.

 I am merely speculating here, but I could imagine that lots of things that provide incremental updating and caching functionality depend on no games being played with the modification date, in which case even if you did find some way to do this, you wouldn't want to.   I'd suggest storing some custom property like "original-mod-date" if this info is important to maintain.

Jerome De selected this answer as the correct answer

Jerome De commented Jul 26 '17, 9:31 a.m.

Yes, I thought the same and it is what I did (

But this limitation makes it impossible to develop a rather exact migration tool using only the API :-(


2 other answers

permanent link
Sudipto Sarkar (631443) | answered Jun 26 '17, 9:19 a.m.

The return type of date field should be: timestamp. 

So, final return type should be :, 
return new Timestamp(date. GetTime());

Jerome De commented Jun 26 '17, 9:25 a.m.

Thanks, but it is not helping with my question.

permanent link
Ralph Schoon (63.3k33646) | answered Jun 26 '17, 9:28 a.m.
edited Jun 26 '17, 9:37 a.m.

I have tried that and have not been able to change the modified date so far in the Java API, as this seems to be encapsulated in the API and the modification date is set when performing the save operation based on the server system time. I was able to change the creation date and the creator, but not the modification date since IWorkItem does not expose methods to set the values. I looked again today and found some promising methods on the implementation classes for the IWorkItem interface. Any IWorkItem implements the implementation class, so the cast should be ok. So you can try the following (No guarantee that the change does not get overwritten though. I don't have the time to try it out.):



Jerome De commented Jun 26 '17, 9:44 a.m.

Thanks a lot, Ralph! (And yes, there would also be the person who modifies to override). I tried your suggestion, but, unfortunately, it looks like the save() on the working copy sets the modification time back to the server time... :-(

Ralph Schoon commented Jun 26 '17, 9:55 a.m. | edited Jun 26 '17, 9:55 a.m.

That was my fear and my current experience as well. has the methods as well.

You can search for where the methods are used in the SDK and maybe find a way. I am not very optimistic though. 

Jerome De commented Jun 26 '17, 11:33 a.m.

Trying to tweak doesn't work either.
I guess the date/user is updated in the save() anyway...
Thanks again.

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.