Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Is there way to get all WTDocument of specific type in windchill through code.
Solved! Go to Solution.
QuerySpec qs = new QuerySpec(WTDocument.class);
TypeDefinitionReference typeRef = TypedUtilityServiceHelper.service.getTypeDefinitionReference("com.xxx.xxx");//Type
SearchCondition searchType = new SearchCondition(WTDocument.class, WTDocument.TYPE_DEFINITION_REFERENCE + "."+
TypeDefinitionReference.KEY + "." + TypeDefinitionForeignKey.BRANCH_ID, SearchCondition.EQUAL,typeRef.getKey().getBranchId());
qs.appendWhere(searchType, new int[] { 0 });
qs.appendAnd();
qs.appendWhere(new SearchCondition(WTDocument.class, WTDocument.LATEST_ITERATION, SearchCondition.IS_TRUE),new int[] { 0 });
QueryResult allDocResult = PersistenceHelper.manager.find((StatementSpec) qs);
QuerySpec qs = new QuerySpec(WTDocument.class);
TypeDefinitionReference typeRef = TypedUtilityServiceHelper.service.getTypeDefinitionReference("com.xxx.xxx");//Type
SearchCondition searchType = new SearchCondition(WTDocument.class, WTDocument.TYPE_DEFINITION_REFERENCE + "."+
TypeDefinitionReference.KEY + "." + TypeDefinitionForeignKey.BRANCH_ID, SearchCondition.EQUAL,typeRef.getKey().getBranchId());
qs.appendWhere(searchType, new int[] { 0 });
qs.appendAnd();
qs.appendWhere(new SearchCondition(WTDocument.class, WTDocument.LATEST_ITERATION, SearchCondition.IS_TRUE),new int[] { 0 });
QueryResult allDocResult = PersistenceHelper.manager.find((StatementSpec) qs);