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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Working with QueryResult in Workflow Expression

Stanley
12-Amethyst

Working with QueryResult in Workflow Expression

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();
}

1 REPLY 1
Stanley
12-Amethyst
(To:Stanley)

I used wt.epm.EPMDocumentMaster.class instead of Versioned.class and it's working now.

Announcements


Top Tags