how to write query to get Documents in a particular product?
Hello,
I am new in windchill customization, i am to write a query to get all the documents( say type "x") in a product(say "y"). Can somebody help???
Hello,
I am new in windchill customization, i am to write a query to get all the documents( say type "x") in a product(say "y"). Can somebody help???
Well, it is returning array, use the following code to get pass the error
QuerySpec queryspec = new QuerySpec(WTDocumentMaster.class);
queryspec.setAdvancedQueryEnabled(true);
int contIndex = queryspec.appendClassList(PDMLinkProduct.class,false);
SearchCondition sc1 = new SearchCondition(WTDocumentMaster.class, "containerReference.key.id",PDMLinkProduct.class, wt.util.WTAttributeNameIfc.ID_NAME);
queryspec.appendWhere(sc1, new int[] { 0, contIndex });
queryspec.appendAnd();
SearchCondition scSWPart = new SearchCondition(PDMLinkProduct.class ,"containerInfo.name",SearchCondition.EQUAL,"TestProduct1",true);
queryspec.appendWhere(scSWPart,new int[] { contIndex });
QueryResult queryResult = PersistenceHelper.manager.find(queryspec);
System.out.println("Size :- " + queryResult.size());
int size = queryResult.size();
System.out.println("WTDocument query result size: " + size);
while (queryResult.hasMoreElements()) {
wt.fc.Persistable persisArray []= (Persistable[]) queryResult.nextElement();
wt.doc.WTDocumentMaster doc=(WTDocumentMaster) persisArray[0];
System.out.println(doc);
}
Regards,
Bhushan
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.