Daniel,
The clue to what's wrong is actually in the error thrown: "java.lang.ClassCastException: wt.maturity.PromotionNotice cannot be cast to wt.part.WTPart" which is due to wt.part.WTPart prt = (wt.part.WTPart)primaryBusinessObject;. In a Promotion Notice workflow the primaryBusinessObject is a PromotionNotice object. You can not just cast that to a WTPart. Luckily there is a helper method which given your pn object can query for the object(s) the user wants to promote. So replace the broken line with something like this:
wt.fc.WTObject obj;
wt.fc.QueryResult queryresult = wt.maturity.MaturityHelper.service.getPromotionTargets(pn);
while (queryresult.hasMoreElements()) {
obj = (wt.fc.WTObject) queryresult.nextElement();
if (obj instanceof wt.part.WTPart) {
// ... cast to WTPart and query for name/number here ...
}
}
Depending on your use case you probably want to add some extra handling there to account for other types of objects that your users can (try to) promote whith proper error handling etc.
In general regarding the Windchill API look for wt.<sometype>.XxxHelper.service.someMethod() if you have a wt.<somepackage>.SomeClass which does not give you the methods you need. Also read up on wt.fc.QueryResult and friends it's useful all over the place as a common Windchill pattern.
Cheers,
Jorn