Skip to main content
17-Peridot
June 6, 2023
Solved

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

  • June 6, 2023
  • 2 replies
  • 2770 views

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());
 }
 }

 

 

 

Best answer by BjoernRueegg

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

2 replies

13-Aquamarine
June 6, 2023

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

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

}

 

17-Peridot
June 7, 2023

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

VladiSlav17-PeridotAuthor
17-Peridot
June 8, 2023

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