Skip to main content
5-Regular Member
April 3, 2025
Solved

Intercept the checkin event of a wtpart

  • April 3, 2025
  • 3 replies
  • 625 views
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.
    Best answer by Shreyas_Atre

    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

     

    3 replies

    joe_morton
    18-Opal
    18-Opal
    April 4, 2025

    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.

    18-Opal
    April 4, 2025

    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!

    12-Amethyst
    April 4, 2025

    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