Conditional routing based on Document attributes
Hello all. Please help. I have an attribute indicating level of required approval rigour on documents and would like to route based on the value of the attribute. I'm not a java guru but, I have used an expression robot with the code below. I seem to be falling foul of the variable 'attrValues' and cannot understand why.
What I want to do is check the value of the IBA 'DocumentLevel' for all documents (there could be more than one) in the promotion notice and pass each individual value to a variable DocLevel. After that, a conditional task queries DocLevel to route accordingly based on the highest level.
Thanks in advance
Expression Code below: :-
+++++++++++++++++++++++++++++++++++++
//Use promotion request as basis.
wt.maturity.PromotionNotice promotionNotice = (wt.maturity.PromotionNotice) primaryBusinessObject;
System.out.println("promotionNotice: " + promotionNotice);
//Get all objects on the promotion request.
wt.fc.WTObject obj;
wt.fc.QueryResult queryResult = wt.maturity.MaturityHelper.service.getPromotionTargets(promotionNotice);
while (queryResult.hasMoreElements()) {
obj = (wt.fc.WTObject) queryResult.nextElement();
//MUltiple subtypes of wt.doc.WTDocument in use. so I'm using it as a catch-all of all doc types
if (obj instanceof wt.doc.WTDocument) {
//Get attribute values on the documents.
wt.doc.WTDocument doc = (wt.doc.WTDocument)obj;
com.ptc.core.lwc.server.PersistableAdapter attr = new com.ptc.core.lwc.server.PersistableAdapter(doc,null,null,null);
attr.load("DocumentLevel"); //internal name of the IBA
String attrValues = null;
DocLevel = (String)attr.get("DocumentLevel");
System.out.println("attrValues: " + attrValues);
//Check if workflow variable contains attribute vaules already and append if it doesn't.
if (DocLevel.isEmpty()) {
DocLevel = attrValues;
} else {
if (!DocLevel.contains(attrValues)) {
DocLevel += "," + attrValues;
}
}
}
}
System.out.println("DocLevel: " + DocLevel);

