Community Tip - You can change your system assigned username to something more personal in your community settings. X
wt.change2.WTChangeActivity2 changeTask = (wt.change2.WTChangeActivity2) primaryBusinessObject;
java.util.Vector results = com.ptc.windchill.enterprise.changeable.ChangeableDataFactory.getResultingObjects(changeTask);
Solved! Go to Solution.
I'm happy to share I believe I have something that works! I didn't realize that I needed to Cast to a Workable since the checkout method was being cast to a changeable. The following expression successfully checked out the files, applied the desired string to the attribute on each resulting object (I did test to make sure it worked on multiple) and then checked the files back in. Thank you for your help!
Could you share some more of the code you're trying?
Essentially I think you need to navigate from the ECN to the Resulting Objects. A first step would be this: https://www.ptc.com/en/support/article/CS55955?source=search
PA_11085333
You can use this code snippet
ChangeActivity2 changeActivity = (ChangeActivity2) primaryBusinessObject;
QueryResult theChangeablesAfterResult = ChangeHelper2.service.getChangeablesAfter(changeActivity,
false);
while (theChangeablesAfterResult.hasMoreElements()) {
Object element = theChangeablesAfterResult.nextElement();
if (element instanceof ChangeRecord2) {
changeRecord = (ChangeRecord2) element;
Changeable2 theChangeable = changeRecord.getChangeable2();
Thank you both for the responses! I've used your suggestions to get to the below state of the expression. The issue I'm having now is that " ChangeHelper2.service.getChangeablesAfter" is returning the error:
" error: package ChangeHelper2 does not exist".
When I search for it in the JavaDoc, ChangeHelper2 doesn't have the getChangeablesAfter method. What does have that method is what @joe_morton suggested, (wt.change2.ChangeService2.getChangeablesAfter) but that returns the error:
"error: non-static method getChangeablesAfter(ChangeActivityIfc,boolean) cannot be referenced from a static context".
Below is the entire code I'm working with. I'm going to continue playing around to see what I can get going but I do believe this is great progress!
______________________________________________________________________________________________________________
wt.change2.ChangeActivity2 changeActivity = (wt.change2.ChangeActivity2) primaryBusinessObject;
wt.fc.QueryResult theChangeablesAfterResult = ChangeHelper2.service.getChangeablesAfter(changeActivity,false);
while (theChangeablesAfterResult.hasMoreElements()) {
Object element = theChangeablesAfterResult.nextElement();
if (element instanceof wt.change2.ChangeRecord2) {
wt.change2.ChangeRecord2 changeRecord = (wt.change2.ChangeRecord2) element;
wt.change2.Changeable2 theChangeable = (wt.change2.Changeable2) changeRecord.getChangeable2();
com.ptc.core.lwc.server.PersistableAdapter adapter = new com.ptc.core.lwc.server.PersistableAdapter(theChangeable,null,null,new com.ptc.core.meta.common.UpdateOperationIdentifier());
// Load the attribute
adapter.load("Watermark");
// Set the new value
adapter.set("Watermark", "TestWatermark");
// Apply the change
adapter.apply();
// Save to database
PersistenceHelper.manager.modify(theChangeable);
}
}
An Update: It looks like I needed to change "ChangeHelper2.service.getChangeablesAfter" to "wt.change2.ChangeHelper2.service.getChangeablesAfter". This made the Syntax acceptable for the Expression Robot. I ran this and the expression got hung up. I can see from the WfUserWorkQueue that the issue is that the file isn't being checked out before it's updated. I'm currently working through making that happen. This is what I have so far but it's not functional:
I'm happy to share I believe I have something that works! I didn't realize that I needed to Cast to a Workable since the checkout method was being cast to a changeable. The following expression successfully checked out the files, applied the desired string to the attribute on each resulting object (I did test to make sure it worked on multiple) and then checked the files back in. Thank you for your help!
