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

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Get Affected Objects, Resulting Objects with Change Request Number

aachanta
13-Aquamarine

Get Affected Objects, Resulting Objects with Change Request Number

Hi All, I would like to know if we just pass a Change Request Number as parameter how would I get the Affected Objects, Resulting Objects, Change Notices or Change Tasks that are associated for a part. Can anyone please let me know the API or code accordingly for that. Thanks and Regards, Aditya
2 REPLIES 2
bcedar
14-Alexandrite
(To:aachanta)

Using this article; 

https://www.ptc.com/en/support/article?n=CS63595&language=en&posno=1&q=understand%20change&source=search

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:

 

ECRAffectedObjects.png

 

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)

 

 

 

Top Tags