How to fix workItems with creationDate main field set to none, but with a correct creationDate in the History?
2 answers
one way is to set the creation date as system property date so that both the dates I.e. on the work item and history are in sync.
DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date();
IWorkItem wi=client.findWorkItemById(workItemId, IWorkItem.FULL_PROFILE, monitor);
IWorkItemWorkingCopyManager manager= client.getWorkItemWorkingCopyManager();
manager.connect(handle, IWorkItem.FULL_PROFILE, monitor);
wc = manager.getWorkingCopy(handle);
wi.setCreationDate(new Timestamp(date.getTime()));
wc.save(null);
This should update the workitem's creation date as system date.
Date date = new Date();
IWorkItem wi=client.findWorkItemById(workItemId, IWorkItem.FULL_PROFILE, monitor);
IWorkItemWorkingCopyManager manager= client.getWorkItemWorkingCopyManager();
manager.connect(handle, IWorkItem.FULL_PROFILE, monitor);
wc = manager.getWorkingCopy(handle);
wi.setCreationDate(new Timestamp(date.getTime()));
wc.save(null);
This should update the workitem's creation date as system date.