The PTC Community is on temporary read only status in preparation for moving our community to a new platform. Learn more here
I have a Promotion request that uses a conditional Router to route depending on object type.
I have used the one from the KB that works well,
shown below.
try
{
wt.fc.QueryResult qr = wt.maturity.MaturityHelper.service.getPromotionTargets((wt.maturity.PromotionNotice)primaryBusinessObject);
while(qr.hasMoreElements())
{
wt.fc.Persistable pers = (wt.fc.Persistable) qr.nextElement();
if (pers.getClass().getName().equalsIgnoreCase("wt.doc.WTDocument"))
{
System.out.println(" ******** It is a WTDocument ******** ");
result = "route1";
}
else if (pers.getClass().getName().equalsIgnoreCase("wt.part.WTPart"))
{
System.out.println(" ******** It is a WTPart ******** ");
result = "route2";
}
else
{
System.out.println(" ******** It is neither WTDocument nor WTPart ******** ");
System.out.println(" ******** Routing to default Document path ******** ");
result = "route1";
}
}
}
catch (Exception e) {
}
The problem that i have is that i want to route for a specific document subtype.
Lets say its com.ptc.General
replacing wt.doc.WTDocument with com.ptc.General or wt.doc.WTDocument|com.ptc.General doesent seem to work.
Are there any java gurus out there that can help?
Solved! Go to Solution.
Hi @BryanK,
After verifying that the object instance is of type WTDocument, you should implement your logic by checking the specific subtype of the WTDocument.
if (pers.getClass().getName().equalsIgnoreCase("wt.doc.WTDocument"))
{
System.out.println(" ******** It is a WTDocument ******** ");
if (TypedUtilityServiceHelper.service.getTypeIdentifier(pers).toString()
.equals("WCTYPE|wt.doc.WTDocument|com.ptc.General")) {
System.out.println(" ******** It is a General Document ******** ");
result = "route1";
} else {
result = "route3";
}
}
Hi @BryanK,
After verifying that the object instance is of type WTDocument, you should implement your logic by checking the specific subtype of the WTDocument.
if (pers.getClass().getName().equalsIgnoreCase("wt.doc.WTDocument"))
{
System.out.println(" ******** It is a WTDocument ******** ");
if (TypedUtilityServiceHelper.service.getTypeIdentifier(pers).toString()
.equals("WCTYPE|wt.doc.WTDocument|com.ptc.General")) {
System.out.println(" ******** It is a General Document ******** ");
result = "route1";
} else {
result = "route3";
}
}
@TDT , nice work. @BryanK , best practice for code in workflows is to externalize this in a custom class. You can have some code like passing in the PromotionNotice. This is important since if you find a bug or it throws can exception, the running workflows cannot be updated. They would have to be terminated and restarted. You might also think about creating a lookup file to map types to routes so that code does not need to change if you decide to change routes or support new types.
Hi,
This is valuable input, at the moment I'm doing a proof of concept to check that the logic will work, still need to work with the team to see if this will work for them, if it does we will look to create it more "robust and configurable"
Cheers,
B
Hi,
Thanks very much this is pretty much what i was looking for I had to change some code as a kept getting errors but i have it working now.
if (TypedUtilityServiceHelper.service.getTypeIdentifier(pers).toString()
Changed to
wt.type.TypedUtilityServiceHelper.service.getTypeIdentifier
