Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X
Using this article;
or
https://www.ptc.com/en/support/article?n=CS268023&language=en&posno=2&q=understand%20change&source=search
You can find out what the linking classes are between your change request and the other objects (take note that the tables you want actually relate to the Change Notice, NOT the Change Request).
Then you can use the wt.fc.PersistenceHelper.manager.navigate(Persistable obj, String role, Class linkClass, boolean onlyOtherSide) function to pull the information you want through the link. So for your example...
wt.change2.WTChangeRequest2 tgtCR = ... (how ever you decide to get your Change Request) wt.fc.QueryResult relatedCnQr = wt.fc.PersistenceHelper.manager.navigate(tgtCR, wt.change2.AddressedBy2.CHANGE_ORDER2_ROLE, wt.change2.AddressedBy2, true); while (relatedCnQr.hasMoreElements()) { wt.change2.WTChangeOrder2 thisCN = (wt.change2.WTChangeOrder2)relatedCnQr.nextElement(); ... do things from each related Change Notice to get to the Affected Objects, Resulting Objects, and Change Tasks. }
Here is an working example to retrieve AffectedObjects from Change Request:
Consider below UI for reference:
Below is my sample code:
public static void main(String[] args) throws ObjectNoLongerExistsException, WTException { QuerySpec qs = null; QueryResult qr = null; qs = new QuerySpec(WTChangeRequest2.class); qs.appendWhere( new SearchCondition(WTChangeRequest2.class, WTChangeRequest2.NUMBER, SearchCondition.EQUAL, "00061",false), new int[] {}); System.out.println(" QS :: " + qs); qr = PersistenceHelper.manager.find((StatementSpec)qs); System.out.println(" ECR Queried :: " + qr.size()); while (qr.hasMoreElements()) { WTChangeRequest2 changeRequest = (WTChangeRequest2) qr.nextElement(); System.out.println(" ECR Numbar :: " + changeRequest.getNumber()); wt.fc.QueryResult qr2 = wt.change2.ChangeHelper2.service.getChangeables(changeRequest, true); while (qr2.hasMoreElements()) { Object obj = qr2.nextElement(); if (obj instanceof wt.enterprise.RevisionControlled) { wt.lifecycle.LifeCycleManaged lifecycleManaged = (wt.lifecycle.LifeCycleManaged) obj; System.out.println("" + lifecycleManaged.getIdentity()); } } } }
Here is what I got as an output:
QS :: SELECT A0.* FROM wt.change2.WTChangeRequest2 A0 WHERE (WTCHGREQUESTNUMBER = '00061') joins=null useBind=true [00061] ECR Queried :: 1 ECR Numbar :: 00061 0000000021, sdfv, <object_name>, A (Design)