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

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

Removing Pending Change icon from Resulting Object when Task is Complete

TWil24
7-Bedrock

Removing Pending Change icon from Resulting Object when Task is Complete

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 */ 
}

 

 

6 REPLIES 6

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

 

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

}

 

 

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

 

Thanks for the insight @BjoernRueegg . Doing some research into the original approveHangingChanges method that accepts a ChangeOrder as parameter. Would want to implement it the same way, setting it to false probably loses the history of the pending change. Not sure yet, just throwing thoughts out.

I never used the service for the one complete CN, as I only paid attention to a few exceptions and processed them with the provided code snippet.


@BjoernRueegg wrote:

I never used the service for the one complete CN, as I only paid attention to a few exceptions and processed them with the provided code snippet.


Would want to implement it the same way, setting it to false probably loses the history of the pending change. Not sure yet, just throwing thoughts out.

Announcements

Top Tags