Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Hi,
please, can you help me with Workflow expression?
We are currently on Windchill 9.1.
I'm trying to export all assemblies from promotion and it's structure to text file (tsv).
Everything is working fine until I reach this line
versionedDoc = (wt.vc.Versioned)qrEPMDocumentMasters.nextElement();
I can not process the second QueryResult, I think it should be full of EPMDocumentMasters.
What am I doing wrong?
Thanks
try {
wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult qr = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
wt.vc.Versioned tv = null;
wt.epm.EPMDocument myDoc;
wt.fc.QueryResult qrEPMDocumentMasters;
wt.vc.Versioned versionedDoc = null;
if (qr != null) {
java.io.FileWriter outputStream = null;outputStream = new java.io.FileWriter("C:\\promotion\\EXPORT.tsv");
try {
while(qr.hasMoreElements()){
tv = (wt.vc.Versioned)qr.nextElement();if (tv instanceof wt.epm.EPMDocument) {
myDoc = (wt.epm.EPMDocument)tv;
if (myDoc.getDocType().getStringValue().equals("wt.epm.EPMDocumentType.CADASSEMBLY") && myDoc.isGeneric() != true) {
outputStream.write("Assembly: " + myDoc.getCADName() + "\r\n");
wt.query.QuerySpec querySpec = new wt.query.QuerySpec(wt.epm.EPMDocumentMaster.class, wt.epm.structure.EPMMemberLink.class);
qrEPMDocumentMasters = wt.epm.structure.EPMStructureHelper.service.navigateUses(myDoc, querySpec, true);
outputStream.write(qrEPMDocumentMasters.size() + " 1 \r\n");
if (qrEPMDocumentMasters != null) {
outputStream.write(qrEPMDocumentMasters.size() + " 2 \r\n");
while (qrEPMDocumentMasters.hasMoreElements()) {
versionedDoc = (wt.vc.Versioned)qrEPMDocumentMasters.nextElement();
outputStream.write(qrEPMDocumentMasters.size() + " 3 \r\n");
if (versionedDoc instanceof wt.epm.EPMDocumentMaster) {
outputStream.write(qrEPMDocumentMasters.size() + " EPMDocumentMaster \r\n");
}
}
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
outputStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
I used wt.epm.EPMDocumentMaster.class instead of Versioned.class and it's working now.
