Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X
I need to be able to pull the Problem Reports that are associated to a WTChangeOrder2. Is there some code that could do this? Thanks!
Relatively simple query builder report will provide. Relationships: Change Notice <> Change Request <> Problem Report(s)
Contact me if you need further info
As Mike L stated, you have can extract using query builders.
Problem reports => Change Request and then Change Request => Change Order.
Below is SQL that extracts only Problem Reports linked to Change Request. I'm only providing you this so you can understand how the WC DB stores and joins this data. All; yes i know, you want to stay away from SQL to the WC DB and use the WC API.
select crm.name as CRNumber, crm.wtchgrequestnumber, cim.wtchgissuenumber PR_Number, cim.name as PR_Name
from wtchangerequest2master crm, formalizedby cil, wtchangeissuemaster cim , controlbranch ca, controlbranch cb
where ca.ida2a2 = cil.branchida3a5
and cb.ida2a2 = cil.branchida3b5
and ca.ida3b5 = crm.ida2a2
and cb.ida3b5 = cim.ida2a2;
This will get you from a change order to the problem reports. All the methods you need to reverse the query are in the wt.change2.ChangeHelper2 service
WTChangeOrder2 co = (WTChangeOrder2)new ReferenceFactory().getReference("OR:wt.change2.WTChangeOrder2:333332323").getObject();
System.out.println(co);
QueryResult crs = ChangeHelper2.service.getChangeRequest(co);
while(crs.hasMoreElements()) {
WTChangeRequest2 cr = (WTChangeRequest2)crs.nextElement();
System.out.println("\t" + cr);
QueryResult prs = ChangeHelper2.service.getChangeIssues(cr);
while(prs.hasMoreElements()) {
WTChangeIssue pr = (WTChangeIssue)prs.nextElement();
System.out.println("\t\t" + pr);
}
}