Skip to main content
7-Bedrock
June 18, 2021
Question

Removing Pending Change icon from Resulting Object when Task is Complete

  • June 18, 2021
  • 1 reply
  • 3382 views

Hi, I am working on some code that would remove the pending change icon from resulting objects when a change task is complete. I am not sure how to get to the pending change of the resulting objects via java/sql query.

 

OOTB, the pending change icon is removed when the Change Notice is complete. However, we would like it to be removed when the change task is complete. In the Change Notice workflow, there's an action to approve the hanging changes (think this is the pending changes) after the entire CN is done. Comes from the api call com.ptc.windchill.pdmlink.change.server.impl.WorkflowProcessHelper.approveHangingChanges(CN).

 

Basically want this to be done on the task and not the entire notice.

 

Have some pseudo code below but not sure how to figure out what resulting object has a pending change.

 

 

public void tasksFinder(changeNotice) {

Query to find tasks in CN

//Looking for this still

 

//Once task completes, run approvedHangingChanges

for each task in CN (do I use includedin link??)

If (task == COMPLETE){

approveHangingChanges(task)

}

}

 

public void approveHangingChanges(ChangeActivityIfc changeActivity) throws WTException (

// this is finding resulting objects in task
QueryResult qs = ChangeHelper2.service.getChangeablesAfter(changeActivity)

while (qs.hasMoreElements()) {

//Not sure how to change pendingchange on each resulting object.

 /* Object obj = (Object) qs.nextElement();
if (obj.pendingChange == 1) {
obj.pendingChange = 0 */ 
}

 

 

1 reply

17-Peridot
June 21, 2021

The problem ist, that you can't change any attribute without checkout/checkin. There is a "unsupported" API to change the value without any access right check. So be careful using this.

Persistable persistable = (Persistable) qs.nextElement();
if(persistable instance of WTPart){
 WTPart wtPart = (WTPart) persistable;
 wtPart.setHasPendingChange(false);
 PersistenceServerHelper.manager.update(wtPart,false);
}

 

TWil247-BedrockAuthor
7-Bedrock
June 21, 2021

Thanks @BjoernRueegg for the response.

 

Question, sorry if it's a silly one, relatively new to WC.

 

Is there a particular reason you're looking for only instances of WTPart instead of just approving all Pending Changes regardless of object type?

 

Is it problematic if I did..

 

// this is finding resulting objects in task (changeable)
QueryResult qs = ChangeHelper2.service.getChangeablesAfter(changeActivity);

while (qs.hasMoreElements()) {

Persistable changeable = (Persistable) qs.nextElement();

if(changeable.isHasPendingChange(true)) {

changeable.setHasPendingChange(false));

}

 

 

17-Peridot
June 21, 2021

The answer is easy. This was a code snippet I used once and that was just for WTParts.

Persistable doesn't has the method "hasPendingChange". If you would like to do it for all objects, then you could use the super class Changeable2.

Persistable persistable = (Persistable) qs.nextElement();
if(persistable instance of Changeable2){
 Changeable2 changeable = (Changeable2) persistable;
 changeable.setHasPendingChange(false);
 PersistenceServerHelper.manager.update(changeable,false);
}