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

Community Tip - If community subscription notifications are filling up your inbox you can set up a daily digest and get all your notifications in a single email. X

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

VladiSlav
17-Peridot

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

 

 

 

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

6 REPLIES 6

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

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

}

 

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

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

BjoernRueegg ,please tell me if you have a code to remove objects from the request

You need find the link and delete the link.

Use the Helper class 

ChangeHelper2.service.

and than the method you need. If you use the method e.g.

ChangeHelper2.service.getChangeablesAfter(changenotice, false);

then you will receive the links and not the objects. Iterate thru the result and delete the link you don't need anymore.

BjoernRueegg ,thank you very much

Announcements

Top Tags