Fetch Workitems which are modified last 24 hours(1day)
We want to retrieve workItems modified from yesterday (last 24 hours). We have tried as below but it didn't fetch WI's correctly. Please let us know what can be wrong? Not sure IWorkItem.MODIFIED_PROPERTY is the correct one to declare here.
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -1);
Date yesterdayDate = cal.getTime();
Timestamp yesterdayTimestamp = new Timestamp(yesterdayDate.getTime());
IQueryableAttribute lastModifiedAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.MODIFIED_PROPERTY, auditableClient, monitor);
Expression lastModifiedExpression = new AttributeExpression(lastModifiedAttribute, AttributeOperation.AFTER, yesterdayTimestamp);
com.ibm.team.workitem.common.query.IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, lastModifiedExpression, IWorkItem.FULL_PROFILE);
----------------
Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -1);
Date yesterdayDate = cal.getTime();
Timestamp yesterdayTimestamp = new Timestamp(yesterdayDate.getTime());
IQueryableAttribute lastModifiedAttribute = QueryableAttributes.getFactory(IWorkItem.ITEM_TYPE).findAttribute(projectArea, IWorkItem.MODIFIED_PROPERTY, auditableClient, monitor);
Expression lastModifiedExpression = new AttributeExpression(lastModifiedAttribute, AttributeOperation.AFTER, yesterdayTimestamp);
com.ibm.team.workitem.common.query.IQueryResult<IResolvedResult<IWorkItem>> results = queryClient.getResolvedExpressionResults(projectArea, lastModifiedExpression, IWorkItem.FULL_PROFILE);
----------------
One answer
I would assume that that is the correct property. Have you tried that out?
Comments
Thanks for your reply Ralph. I have tried it but it is only considering day not the full timestamp. i mean it is retrieving all workitems modified from yesterday(on yesterday date) but not from yesterday timestamp.
yes, the filter only uses day.. not time. so you cannot get the rolling last 24 hours exactly.
Comments
Sridhar Kuna
Sep 03 '15, 7:16 a.m.By the way, Workitem modification can be any kind of change either new comment addition, status change or any attribute values changes etc...