Version: Windchill 12.0
Use Case: I want to set a lock on Change Notice creation page to check if user is adding appropriate parts
Description:
I'm using the below code to get affected objects but i'm getting list size as zero.
public class CustomCreateChangeNoticeFormProcessor extends CreateChangeNoticeFormProcessor {
@SuppressWarnings("unchecked")
public FormResult doOperation(NmCommandBean arg0, List<ObjectBean> arg1) throws WTException {
for (ObjectBean bean : arg1) {
if ((bean.getObject() instanceof WTChangeOrder2)) {
WTChangeOrder2 ecn = (WTChangeOrder2) bean.getObject();
System.out.println("ECN : " + ecn.getName());
String softTypeECN = TypeIdentifierHelper.getType(ecn).toString();
List<NmOid> affectedItemList = bean.getAddedItemsByName("changeNotice.wizardImplementationPlan.table");
System.out.println("List size 1 affected: "+affectedItemList.size());
List<NmOid> affectedInitialItemList = bean.getInitialItemsByName("changeNotice.wizardImplementationPlan.table");
System.out.println("List size 2 affected initial: "+affectedInitialItemList.size());
affectedItemList.addAll(affectedInitialItemList);
System.out.println("List size 3 total: "+affectedItemList.size());
for (NmOid nmo : affectedItemList) {
Object obj = nmo.getRefObject();
System.out.println("OBJ : "+ obj);
if (obj instanceof WTChangeActivity2) {
WTChangeActivity2 changeActivity = (WTChangeActivity2) obj;
System.out.println(changeActivity.getName()+" "+changeActivity.getName()+": Change activity found");
QueryResult affectedObjects = ChangeHelper2.service.getChangeablesBefore(changeActivity);
System.out.println("affectedObjects Size: " + affectedObjects.size());
String plannerCode="NA";
while (affectedObjects.hasMoreElements()) {
WTObject obj1 = (WTObject) affectedObjects.nextElement();
if (obj1 instanceof WTPart) {
WTPart part = (WTPart) obj1;
String partNumber = part.getNumber();
}
}
}
}
}
}
System.out.println("CreateChangeNoticeFormProcessor End");
return super.doOperation(arg0, arg1);
}
}