Solved
I want to retrieve the part attribute
I have the change Notice Number. From the changenotice number get the changables after from the changables i want only part. From that part i want to retrieve the attribute "Material_Type".
I have the change Notice Number. From the changenotice number get the changables after from the changables i want only part. From that part i want to retrieve the attribute "Material_Type".
Give it a try this way
try {
QuerySpec qs = new QuerySpec(WTChangeOrder2.class);
SearchCondition searchcondition = new SearchCondition(WTChangeOrder2.class, WTChangeOrder2.NUMBER, SearchCondition.EQUAL, "CN0007698");
qs.appendWhere(searchcondition, new int[]{0});
final QueryResult qr = PersistenceHelper.manager.find(qs);
while (qr.hasMoreElements()) {
WTChangeOrder2 ecn = (WTChangeOrder2) qr.nextElement();
System.out.println(" Found Change Order Number: " + ecn.getNumber());
ReferenceFactory rf = new ReferenceFactory();
WTReference reference = (WTReference) rf.getReference(ecn);
WTChangeOrder2 changeNotice = (WTChangeOrder2) reference.getObject();
QueryResult qr2 = wt.change2.ChangeHelper2.service.getChangeablesAfter(changeNotice, false);
while (qr2.hasMoreElements()) {
ChangeRecord2 record = (ChangeRecord2) qr2.nextElement();
Changeable2 changeable = record.getChangeable2();
System.out.println("Branch :" + changeable.getBranchIdentifier());
ReferenceFactory rf2 = new ReferenceFactory();
WTReference changeablereference = (WTReference) rf2.getReference(changeable);
if (changeable instanceof WTPart) {
System.out.println("WTPartMaster is found");
WTPart part = (WTPart) changeablereference.getObject();
PersistableAdapter obj = new PersistableAdapter(part, null, java.util.Locale.US, new com.ptc.core.meta.common.DisplayOperationIdentifier());
obj.load("MaterialSpec");
String MaterialSpecValue = (java.lang.String) obj.get("MaterialSpec");
System.out.println("MaterialSpec: " + MaterialSpecValue);
if (MaterialSpecValue != null) {
System.out.println("MaterialSpec: " + MaterialSpecValue);
} else {
System.out.println("Material Spec is null");
}
}
}
}
}
catch(Exception exception) {
exception.printStackTrace();
}Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.