Skip to main content
July 16, 2013
Solved

Developing code in Workflow Template Administrator

  • July 16, 2013
  • 1 reply
  • 6248 views

I . . I'm a windchill starter user and i have skills in JAVA , now i'm trying to construct a Expression in Workflow Template Administrator and i need to get the PDF (Representation File) from a EPM Document received in a Promotion Request and copy that to a specific folder ...

I get this piece of code from internet but i get errors showed in bottom...

try{

QueryResult theQueryResult = MaturityHelper.service.getPromotionTargets(thePromotionNotice);

Versioned theVersioned = null ;

if (theQueryResult != null){

while(theQueryResult.hasMoreElements()){

theVersioned = (Versioned)theQueryResult.nextElement();

if (theVersioned instanceof EPMDocument) { ... }

}

}

catch(...){}

//primaryBusinessObject

QueryResult theQueryResult;

wt.maturity.PromotionNotice pn = (wt.maturity.PromotionNotice)primaryBusinessObject;

try{

theQueryResult = MaturityHelper.service.getPromotionTargets(pn);

Versioned theVersioned = null ;

if (theQueryResult != null){

while(theQueryResult.hasMoreElements()){

theVersioned = (Versioned)theQueryResult.nextElement();

if (theVersioned instanceof EPMDocument) {

System.out.println("IS A EPM DOCUMENT");

//É Preciso procurar o PDF AGORA.....

System.out.println("NOW GET THE PDF DOCUMENT");

// . . .

}else{

System.out.println("THIS IS NOT AN EPM");

}

}

}

}catch(Exception e){

System.out.println("ERROR EXPORTING PDF: " + e.getMessage());

errorMsg = "ERROR EXPORTING PDF Promotion Request: " + e.getMessage();

}

Five errors reported in check Syntax..

1) WfExpression45853891.java:36: cannot find symbol

symbol : class QueryResult

location: class wt.workflow.expr.WfExpression45853891

QueryResult theQueryResult;

^

2) WfExpression45853891.java:39: package MaturityHelper does not exist

theQueryResult = MaturityHelper.service.getPromotionTargets(pn);

^

3) WfExpression45853891.java:40: cannot find symbol

symbol : class Versioned

location: class wt.workflow.expr.WfExpression45853891

Versioned theVersioned = null ;

^

4) WfExpression45853891.java:43: cannot find symbol

symbol : class Versioned

location: class wt.workflow.expr.WfExpression45853891

theVersioned = (Versioned)theQueryResult.nextElement();

^

5) WfExpression45853891.java:44: cannot find symbol

symbol : class EPMDocument

location: class wt.workflow.expr.WfExpression45853891

if (theVersioned instanceof EPMDocument) {

I need help here because and dont know all structure of Windchill API classes

Best answer by ybagul

Windchill needs FQN in expression robots for workflow templates. Use following to resolve your errors.

1) wt.fc.QueryResult

2) wt.maturity.MaturityHelper

3) wt.vc.Versioned

4) wt.vc.Versioned

5) wt.epm.EPMDocument

For Windchill JavaDoc, use following link on your 9.1 Windchill server (dont know for 10)

https://myserver.mycompany.com/Windchill/wt/clients/library/api/index.html

1 reply

ybagul1-VisitorAnswer
1-Visitor
July 16, 2013

Windchill needs FQN in expression robots for workflow templates. Use following to resolve your errors.

1) wt.fc.QueryResult

2) wt.maturity.MaturityHelper

3) wt.vc.Versioned

4) wt.vc.Versioned

5) wt.epm.EPMDocument

For Windchill JavaDoc, use following link on your 9.1 Windchill server (dont know for 10)

https://myserver.mycompany.com/Windchill/wt/clients/library/api/index.html

July 17, 2013

Thank you Yogesh Bagul ! it's solved ..

But now i'm with dificult .. i need to know if the object in PBO is a DRW (Creo Drawing)

i have this:

if (theVersioned instanceof wt.epm.EPMDocument) {

System.out.println("IS A EPM DOCUMENT");

myDoc = (wt.epm.EPMDocument)theVersioned;

System.out.println("TYPE OF DOC: " + myDoc.getDocType());
}

But i get CADDRAWING , so i can compare this with

if(myDoc.getDocType().toString().equals("CADDRAWING") ){

..

}

Or exist other way to do this ?

Other question is how can i get the representations of CADDRAWING ?

Because i want the list of Representations, verify if exist any representation in PDF format and after that copy the file to a share in other server. .

Regards !

1-Visitor
July 18, 2013

I guess your validation for CADDRAWING is good enough. To get representations from EPMDocument, look at wt.content.ApplicationData class. You can check and then stream representation file to file share.