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

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

How to get AffectedObjects on CustomCreateChangeNoticeFormProcessor before they persist in Database?

KOEL_PLM
11-Garnet

How to get AffectedObjects on CustomCreateChangeNoticeFormProcessor before they persist in Database?

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);
}
}
 
2 REPLIES 2
rhart
16-Pearl
(To:KOEL_PLM)

Where is the code being called from, queryresult will only find results when the CN object creation has finished

Catalina
Moderator
(To:rhart)

Hi @KOEL_PLM,


I wanted to see if you got the help you needed.


If so, please mark the appropriate reply as the Accepted Solution or please detail what has helped you and mark it as the Accepted SOlution. It will help other members who may have the same question.
Please note that industry experts also review the replies and may eventually accept one of them as solution on your behalf.
Of course, if you have more to share on your issue, please pursue the conversation.

Thanks,

Catalina
PTC Community Moderator
Announcements


Top Tags