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

Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Translate the entire conversation x

Intercept the checkin event of a wtpart

ML_10481993
5-Regular Member

Intercept the checkin event of a wtpart

I am using Windchill PDMLink Release 12.1 and Datecode with CPS 12.1.2.0

We need to intercept the checkin event of a wtpart when the user does the following operations: checks out a wtpart, modifies only its structure links (or adds documents) and checks it in without changing its attributes.
ACCEPTED SOLUTION

Accepted Solutions

How to write a listener? Please refer to the article below:
https://www.ptc.com/en/support/article/CS213788

In your case, you can listen to the pre-checkin listener. In the listener, when you receive a WTPart as the event target in the notifyVetoableEvent method implement your custom attribute comparison logic 

Do not forget to check if the event type is WTPart, because the same event is also triggered for other objects during check-in.

if (eventTarget instanceof WTPart aPart) {
    WTPart oldPart = (WTPart) WorkInProgressHelper.service.originalCopyOf(aPart);
    // 1) Get attributes from the old version in a collection
    // 2) Get attributes from the new version in a collection
    // Compare both collections
    if (!oldAttributes.equals(newAttributes)) {
        throw new Exception("<Custom Error Message >");
    }
}

Refer to the article below to get the attribute values:
https://www.ptc.com/en/support/article/CS135663

Hope this helps,
Thanks

 

View solution in original post

3 REPLIES 3

Sounds like you need to create a "listener" for the WTPart check in event. I don't know the specifics myself, but hopefully that gives you a place to start searching the Support page for.

Would it be more simply stated that you want to prevent checkin if there are no attribute value changes?

 

If yes, as @joe_morton  mentioned a listener can do this quite easily.

Also, you mean Global Atrributes not any attribute because the iteration itself is an attribute and of course that would ALWAYS be different with every check in.

 

I write custom  listeners all the time to do whatever including validations at checkin.

In this case you simple need to compare attribute values of the checked in iteration with those of the previous iteration. If there are no differences, May Day!

How to write a listener? Please refer to the article below:
https://www.ptc.com/en/support/article/CS213788

In your case, you can listen to the pre-checkin listener. In the listener, when you receive a WTPart as the event target in the notifyVetoableEvent method implement your custom attribute comparison logic 

Do not forget to check if the event type is WTPart, because the same event is also triggered for other objects during check-in.

if (eventTarget instanceof WTPart aPart) {
    WTPart oldPart = (WTPart) WorkInProgressHelper.service.originalCopyOf(aPart);
    // 1) Get attributes from the old version in a collection
    // 2) Get attributes from the new version in a collection
    // Compare both collections
    if (!oldAttributes.equals(newAttributes)) {
        throw new Exception("<Custom Error Message >");
    }
}

Refer to the article below to get the attribute values:
https://www.ptc.com/en/support/article/CS135663

Hope this helps,
Thanks

 

Announcements
Top Tags