How to get History data of workitem using RTC Java API

1.9k views Asked by At

Basically I want to read History of workitem to identify whether the workitem is being modified (I am aware that I can use modifiedDate to query records but it is not considering timestamp. Details How to get workitem based on modified date and time using RTC Java API)

It would be helpful if someone can share code to fetch history from RTC using Java API along with modified date of each history record, history record id if avaliable.

1

There are 1 answers

0
Neha S On BEST ANSWER

I got it:

    IWorkItem workItem = workItemClient.findWorkItemById(id, IWorkItem.FULL_PROFILE, monitor);
    System.out.println("Last modified date: "+workItem.modified()+"\n");

    IItemManager itm = teamRepository.itemManager(); 
    List history = itm.fetchAllStateHandles((IAuditableHandle) workItem.getStateHandle(), monitor);
    System.out.println("Record history details:-");
    for(int i = history.size() -1; i >= 0; i--){
        IAuditableHandle audit = (IAuditableHandle) history.get(i);
        IWorkItem workItemPrevious = (IWorkItem) teamRepository.itemManager().fetchCompleteState(audit,null);
        Date recordModifiedDate = workItemPrevious.modified();
        System.out.println("Record modification date: "+recordModifiedDate);
    }