Skip to main content
Jun 6, 2023 12:51 PM UTC
Solved

How to use the java api to add WTDocument to the "Change Summary" table in Change Notice?

I have code to output "Change Summary" object types from a Change Notice
But I do not know how to add more objects to this table, for example, WTDocument

 

public static void printChangeAfter(WTChangeOrder2 wtChangeOrder2) {
 try {
 QueryResult result = ChangeHelper2.service.getChangeActivities(wtChangeOrder2);
 while (result.hasMoreElements()) {
 WTChangeActivity2 activity = (WTChangeActivity2) result.nextElement();
 QueryResult res = ChangeHelper2.service.getChangeablesAfter(activity);

 while (res.hasMoreElements()) {
 WTObject object = (WTObject) res.nextElement();
 System.out.println(object.getType());
 }
 }
 } catch (WTException e) {
 System.out.println("error " + e.getMessage());
 }
 }

 

 

 

Jun 7, 2023 4:45 AM UTC

You can't add any object to the change summary table. This is just the summary of all the change tasks (change activities). You need to add them to a single change task

Vector partVec = new Vector();
partVec.addElement(part); //assuming you have the WTPart object 
partVec = ChangeHelper2.service.storeAssociations(ChangeRecord2.class, task, partVec); //task is Change Activity object
ChangeRecord2 resulting_data = (ChangeRecord2)partVec.firstElement();
resulting_data.setDescription("ChangeRecord2 and a Part");
partVec = ChangeHelper2.service.saveChangeRecord(partVec);

 See https://www.ptc.com/en/support/article/CS122930 or https://www.ptc.com/en/support/article/CS200677

6 replies

Jun 6, 2023 10:57 PM UTC

You can use instanceof to know if object is WTDocument, WTPart etc 

if(object instanceof WTDocument){
WTDocument doc = (WTDocument)Object;

}

 

Jun 7, 2023 4:45 AM UTC

You can't add any object to the change summary table. This is just the summary of all the change tasks (change activities). You need to add them to a single change task

Vector partVec = new Vector();
partVec.addElement(part); //assuming you have the WTPart object 
partVec = ChangeHelper2.service.storeAssociations(ChangeRecord2.class, task, partVec); //task is Change Activity object
ChangeRecord2 resulting_data = (ChangeRecord2)partVec.firstElement();
resulting_data.setDescription("ChangeRecord2 and a Part");
partVec = ChangeHelper2.service.saveChangeRecord(partVec);

 See https://www.ptc.com/en/support/article/CS122930 or https://www.ptc.com/en/support/article/CS200677

VladiSlavAuthor
Jun 8, 2023 10:00 AM UTC

BjoernRueegg ,thank you very much, your code works as I wanted