cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

Translate the entire conversation x

QuerySpec to retrieve the documents using latest modified date

LT_12699133
10-Marble

QuerySpec to retrieve the documents using latest modified date

 


Description:

Version: Windchill 13.0

 

Use Case: Fetch all unique WTDocuments of allowed types, modified on or after a given timestamp, across multiple document types, without duplicates.


Description:

I am using below queryspec however it is not returning the results expected, for example when I do teh search in Windchill advance search it fetched results around 300 but using queryspec it is fetching around 60. I am not sure why this discrepency is happening but please help me if you knwo something here.

 

we can have multiple document type. Also internal name is correct. I have cross checked as well. just fetching few results not entire is confusing me.

 

 
List<Long> typeIds = new ArrayList<>();

 System.out.println("getWTDocumentByLastModifiedDate allowedDocumentTypes>>> "+allowedDocumentTypes);

 QuerySpec qs = new QuerySpec(WTDocument.class); 

for (String typeId : allowedDocumentTypes) {

 System.out.println("getWTDocumentByLastModifiedDate typeId>>> "+typeId);

 TypeDefinitionReference tdRef = TypedUtilityServiceHelper.service.getTypeDefinitionReference(typeId.trim());

typeIds.add(tdRef.getKey().getId());

 }



qs.appendOpenParen();

for (int i = 0; i < typeIds.size(); i++) { 

if (i > 0) {

qs.appendOr();

 }

qs.appendWhere(new SearchCondition(WTDocument.class, "typeDefinitionReference.key.id", SearchCondition.EQUAL, typeIds.get(i)), new int[] { 0 });



 }

qs.appendCloseParen();

qs.appendAnd();

qs.appendWhere(new SearchCondition(WTDocument.class, WTDocument.MODIFY_TIMESTAMP, SearchCondition.GREATER_THAN_OR_EQUAL, timestamp), new int[] { 0 });

 QueryResult qr = PersistenceHelper.manager.find((StatementSpec)qs);

 

1 REPLY 1

Also, I just found out one thing that it is skipping parts which have modified date end with EDT and selecting only EST one's

Announcements
Top Tags