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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Conditional statement for ECR workflow

RajeshBalasunda
1-Newbie

Conditional statement for ECR workflow

Windchill 9.0 M060
I am trying to put a conitional in the ECR workflow which will determine the type of document associated with the ECR. If it is a WT Document it has to follow a path and for all other documents types it takes the other route. Can someone let me know what syntax I need to use in the conditional.




Regards,

Rajesh Balasundaram

2 REPLIES 2

I'm certain there is another way to do this without using a webject - and hopefully someone will share that - but if all else fails this is what I've done to accomplish a similar goal:

wt.fc.QueryResult queryResult = wt.change2.ChangeHelper2.service.getChangeables((wt.change2.ChangeRequestIfc) primaryBusinessObject);
java.util.Enumeration enumer = queryResult.getEnumeration();

while (enumer.hasMoreElements()) {
wt.change2.Changeable2 changeable = (wt.change2.Changeable2) enumer.nextElement();

com.infoengine.SAK.Task task = new com.infoengine.SAK.Task("/myTasks/getObject.xml");
task.setParam("obid", changeable.toString());
task.invoke();

com.infoengine.object.factory.Group group = task.getGroup("results");

String classname = (String) group.getAttributeValue(0, "class");

//TODO process based on soft type

// You'll find that "classname" contains the full soft type name, such as "wt.doc.WTDocument|com.mycompany.MyType"
// If the version of java you are on doesn't support classname.contains("WTDocument") then try (classname.indexOf("WTDocument") > -1)
}

Webject (<windchill_home>/tasks/myTasks/getObject.xml):
<%
//get the windchill instance
String windchill = wt.util.WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName");

String obid = (String)getContextGroup("FORM").getAttributeValue(0,"obid");

if(obid != null) {
%>
<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="INSTANCE" data="&lt;%=windchill%">"/>
<ie:param name="ATTRIBUTE" data="*" delim=","/">
<ie:param name="GROUP_OUT" data="results"/">
<ie:param name="AUTHORIZATION" data="${@server[]authorization[0]}"/">
<ie:param name="OBJECT_REF" data="&lt;%=obid%">"/>
</ie:webject>
<%
}
%>

<ie:webject name="Return-Groups" type="GRP">
<ie:param name="GROUP_IN" data="results"/">
</ie:webject>

I hope that helps!

-Thomas R. Busch
Sr. Software Developer
Stryker Instruments
(269) 323-7700 x4014
tom.busch@stryker.com<">mailto:tom.busch@stryker.com>

I believe you will find code in the following snippet that you can use... this is from a promotion workflow that we use currently in 8 M050.

To route the workflow, I suggest assigning a value to a workflow variable in the code below then you can fire using that value. In the snippet below, I included wtPart - but we only use manufacturer parts and regular wtParts here. In the wtDocument branch, we havea soft type called "Procurement Specifications".

wt.fc.QueryResult qr = wt.maturity.MaturityHelper.service.getPromotionTargets( (wt.maturity.PromotionNotice) primaryBusinessObject);

while (qr.hasMoreElements()) {
Object obj = qr.nextElement();
if (obj instanceof wt.part.WTPart) {
if (obj instanceof com.ptc.windchill.suma.part.ManufacturerPart) {


// DO MFR PART ACTIONS //;


} else {


// DO PART ACTIONS //


}
}
} else {
if (obj instanceof wt.doc.WTDocument) {
wt.doc.WTDocument doc = (wt.doc.WTDocument)obj;
com.ptc.windchill.enterprise.copy.server.CoreMetaUtility cmu = new com.ptc.windchill.enterprise.copy.server.CoreMetaUtility();
String docType = cmu.getLocalizedTypeString((WTObject) doc, wt.session.SessionHelper.getLocale());
if ("Procurement Specifications".equals(docType)) {


// DO DOCUMENT (soft type Procurement Specification) ACTIONS //


}
}
}
}

Top Tags