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

Workflow Customization - Java API Questions

SOLVED
Highlighted
Emerald I

Workflow Customization - Java API Questions

I am trying to customize the email notifications being sent from a workflow but I'm having trouble finding the right Java API calls to use for certain pieces of information.  Here are the calls I'm using so far:

wt.maturity.StandardMaturityService p = new wt.maturity.StandardMaturityService();
wt.maturity.PromotionNotice pn =(wt.maturity.PromotionNotice)primaryBusinessObject;
wt.fc.QueryResult pn_targets;
pn_targets = (wt.fc.QueryResult) p.getBaselineItems(pn);
wt.epm.EPMDocument epmDoc = new wt.epm.EPMDocument();
while (pn_targets.hasMoreElements())
{
     Object obj =pn_targets.nextElement();
     String objType =obj.getClass().getName();
     if (objType.equals("wt.epm.EPMDocument"))
     {
         epmDoc = (wt.epm.EPMDocument)obj;
         System.out.println("state = " + epmDoc.getState().toString());
         System.out.println("number = " + epmDoc.getNumber().toString());
         System.out.println("cadname = " + epmDoc.getCADName());
     }
}

These are working great, but I need more.  What are the calls to get the following:

  • Revision
  • Iteration
  • URL to object's detail page

I'm assuming there is some other method the EPM Document object has to be passed through, but I have no idea what it is.  I've done some looking through the Java Doc, but it is pretty overwhelming.  Any suggestions?

 

Thanks!

 

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Workflow Customization - Java API Questions

 

Property page :

import wt.fc.ReferenceFactory

HashMap map = new HashMap(1);
ReferenceFactory referenceFactory = new ReferenceFactory();

map.put("oid", referenceFactory.getReferenceString(epmDoc));
String url =  urlFactory.getURL("app/#ptc1/tcomp/infoPage", map).toString();

Version & Iteration

// version
epmDoc.getVersionIdentifier().getValue()

// iteration
epmDoc.getIterationIdentifier().getValue()


 

Regards

14 REPLIES 14

Re: Workflow Customization - Java API Questions

 

Property page :

import wt.fc.ReferenceFactory

HashMap map = new HashMap(1);
ReferenceFactory referenceFactory = new ReferenceFactory();

map.put("oid", referenceFactory.getReferenceString(epmDoc));
String url =  urlFactory.getURL("app/#ptc1/tcomp/infoPage", map).toString();

Version & Iteration

// version
epmDoc.getVersionIdentifier().getValue()

// iteration
epmDoc.getIterationIdentifier().getValue()


 

Regards

Re: Workflow Customization - Java API Questions

Where are you finding these?  When I look at the EPMDocument class in the Java Doc, these methods aren't listed.  Should I be looking somewhere else?

Re: Workflow Customization - Java API Questions

Is "import" valid in a workflow expression?

Checking Syntax...
E:\ptc\Windchill_11.0\Windchill\temp\WfExpression395707948.java:36: error: illegal start of expression
import wt.fc.ReferenceFactory;
^
E:\ptc\Windchill_11.0\Windchill\temp\WfExpression395707948.java:36: error: not a statement
import wt.fc.ReferenceFactory;
            ^
2 errors
Syntax check complete.

Re: Workflow Customization - Java API Questions

 

Well the way PTC generates its JavaDoc is strange...

Many things are missing !

 

Re: Workflow Customization - Java API Questions

Ah, no !!!

Workflow expressions end in java methods, so you must  use fully qualified name...

 

like

 

wt.fc.ReferenceFactory referenceFactory = new wt.fc.ReferenceFactory();

Re: Workflow Customization - Java API Questions


@TomU wrote:

Where are you finding these?  When I look at the EPMDocument class in the Java Doc, these methods aren't listed.  Should I be looking somewhere else?


Using an ide, such as Eclipse, will allow you to use auto completion on methods. You will discover many methods not documented or easily found in PTC's java docs. Of course many of these are not "supported" however I have been using "unsupported" methods for a long time. Always good to develop and test on a test server. You can build the code in an ide and then copy and paste over to the workflow expression editor.

 

I have also found many classes and methods from countless searches on this site and also PTC's site.

Re: Workflow Customization - Java API Questions

urlFactory also had to be initialized.  Digging around on the community I found this line:

wt.httpgw.URLFactory urlFactory = new wt.httpgw.URLFactory();

It seems to be working perfectly!  Smiley Happy  I will post the final code block in a little bit.

 

For using these types of calls from a workflow expression, is it recommend to wrap everything in try/catch blocks, or are they fine as shown?  Thanks!

Re: Workflow Customization - Java API Questions

Good :-)

It's a good thing to handle exceptions.

If you don't, the exception ends the workflow...

 

Re: Workflow Customization - Java API Questions

@olivierfresse,

Do you know how I would retrieve the "friendly name" (localized value???) of the lifecycle states?  For example, instead of showing "INWORK" I would like to display "In Work".

epmDoc.getState().toString();