Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X
Solved! Go to Solution.
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
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