Skip to main content
11-Garnet
December 13, 2024
Solved

To get all WTDocument of Specific type in windchill

  • December 13, 2024
  • 1 reply
  • 720 views

Is there way to get all WTDocument of specific type in windchill through code.

Best answer by Daniel_Ada
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);

1 reply

13-Aquamarine
December 13, 2024
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);