Skip to main content
23-Emerald IV
November 16, 2017
Solved

Workflow Customization - Java API Questions

  • November 16, 2017
  • 2 replies
  • 10832 views

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!

 

Best answer by olivierfresse

 

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

2 replies

15-Moonstone
November 16, 2017

 

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

TomU23-Emerald IVAuthor
23-Emerald IV
November 16, 2017

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?

15-Moonstone
November 16, 2017

 

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

Many things are missing !

 

TomU23-Emerald IVAuthor
23-Emerald IV
November 18, 2017

Thank you to everyone for the help.  I have accomplished my objective.  A table with the promotion objects (CAD Documents) has been constructed in a string variable and can be easily added to any task or notification robot email.

 

String:  promotion_objects

Usage: {promotion_objects}

Output:

table_final.PNG

Expression Code:

String style = "style=\"border: 1px solid; border-color:#808080; padding: 2px; padding-left: 6px; padding-right: 6px; font-weight: bold; color: white \"";
String style1 = "style=\"border: 1px solid; border-color:#808080; padding: 2px; padding-left: 6px; padding-right: 6px \"";
String style2 = "style=\"border: 1px solid; border-color:#808080; padding: 2px; padding-left: 6px; padding-right: 6px; background-color: #f7f7f7 \"";

promotion_objects = "<table style=\"font-size: 12px; color: #464646; border: 1px solid; border-color:#808080; font-family: arial; border-collapse: collapse\">\r\n";
promotion_objects = (promotion_objects + "<thead style=\"background-color: #4caf50\"><tr>\r\n");
promotion_objects = (promotion_objects + "<td " + style + ">Number</td><td " + style + ">Name</td><td " + style + ">Version</td><td " + style + ">State</td>\r\n");
promotion_objects = (promotion_objects + "</tr></thead>\r\n");
promotion_objects = (promotion_objects + "<tbody>\r\n");

wt.fc.ReferenceFactory referenceFactory = new wt.fc.ReferenceFactory();
HashMap map = new HashMap(1);
wt.httpgw.URLFactory urlFactory = new wt.httpgw.URLFactory();

Integer i = 1;

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;
 String epmNumber = epmDoc.getNumber().toString();
 String epmName = epmDoc.getName();
 String epmCADName = epmDoc.getCADName();
 String epmVersion = epmDoc.getVersionIdentifier().getValue();
 String epmIteration = epmDoc.getIterationIdentifier().getValue();
 // String epmState = epmDoc.getState().toString();
 String epmState = epmDoc.getLifeCycleState().getDisplay();

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

 promotion_objects = (promotion_objects + "<tr>\r\n");
 if (i == 1) {
 promotion_objects = (promotion_objects + "<td " + style1 + ">" + epmNumber + "</td>\r\n");
 promotion_objects = (promotion_objects + "<td " + style1 + "><a href=\"" + epmURL + "\">" + epmCADName + "</a></td>\r\n");
 promotion_objects = (promotion_objects + "<td " + style1 + ">" + epmVersion + "." + epmIteration + "</td>\r\n");
 promotion_objects = (promotion_objects + "<td " + style1 + ">" + epmState + "</td>\r\n");
 i = 2;
 } else {
 promotion_objects = (promotion_objects + "<td " + style2 + ">" + epmNumber + "</td>\r\n");
 promotion_objects = (promotion_objects + "<td " + style2 + "><a href=\"" + epmURL + "\">" + epmCADName + "</a></td>\r\n");
 promotion_objects = (promotion_objects + "<td " + style2 + ">" + epmVersion + "." + epmIteration + "</td>\r\n");
 promotion_objects = (promotion_objects + "<td " + style2 + ">" + epmState + "</td>\r\n");
 i = 1;
 }
 promotion_objects = (promotion_objects + "</tr>\r\n");
 }
}

promotion_objects = (promotion_objects + "</tbody>\r\n");
promotion_objects = (promotion_objects + "</table>");

System.out.println(promotion_objects);

Note: There is no error checking included.  (I'm really close to the 4000 character limit...)

1-Visitor
January 4, 2021

Hi Folks...

 

I'm poking around the email notifications... the users here aren't impressed with the OOTB and seems like no one here is either.  I came across this post and was happy to see info like this.  I have nube questions though...

 

promotion_objects... how is it that every time that string variable is set... it doesn't over write the last...  it's writing the html text for each cell it looks like... how does it compile all that info using one string variable?

1-Visitor
January 4, 2021

Dang it... always works like that... i ask the question and look at it again and go... ahh there it is... we are just adding to one loooooong string.

 

(is that right?)