Skip to main content
23-Emerald IV
November 11, 2021
Question

Windchill Listener Events - Get Rename Values

  • November 11, 2021
  • 2 replies
  • 2775 views

Does anyone know of a way to retrieve the target values a user enters into the rename GUI before any of the rename events finish?  We're running into a problem where we can't see what the new filename is until after the number change is already complete.  We need to know if the filename is going to be changing, and if so what its new value will be, before we decide whether or not to let the number change proceed.  Since separate events are being fired for name, number, and filename, it seems like it's impossible (from just these events) to tell in advace what is going to be changing.  Instead of just looking at the object passed by these listeners (EPMDocument, etc.) is there some way to get all the data that was actually submitted by the user on the rename form, before any of the rename events actually finish?

 

Rename dialog:

TomU_1-1636672142378.png

 

Event listener order depending on what is being changed:

TomU_0-1636672011173.png

 

2 replies

21-Topaz I
November 15, 2021

I would think getting what someone types in a field and not completing the task by not selecting the OK button is not possible.

 

I have created a report that shows a past name of a file.  Not sure if that would help though.

avillanueva
23-Emerald I
23-Emerald I
November 15, 2021

I have a rename listener and am using a PRE_CHANGE_IDENTITY. Presumably, the target has already been changing but not stored yet. Why else would it be a pre-change event? I get an IdentityServiceEvent returned. I did not see any "pre" identity objects in the event so agree that they are not exposing that. What if you tried this? Using the internal ID of the object, look it up via a query and get the current identity. In this way, you have the modified object passed from the event and a separate database query of that same item to compare against.  

IdentityServiceEvent idEvent=(IdentityServiceEvent)event;

Object target=idEvent.getEventTarget();
logger.debug("Listen hears PRE_CHANGE_IDENTITY: ");
logger.debug(" target:"+target.toString());
if(target instanceof EPMDocumentMaster)
{
EPMDocumentMaster master = (EPMDocumentMaster)target;
EPMDocumentMasterIdentity cadDocID=(EPMDocumentMasterIdentity)idEvent.getIdentity();
logger.debug("New name:"+cadDocID.getName()+":"+cadDocID.getName().length());
String newName=cadDocID.getName();

TomU23-Emerald IVAuthor
23-Emerald IV
November 16, 2021

@avillanueva,

You were right and I was wrong.  The EPMDocumentMasterIdentity class was the difference.  I was using EPMDocumentMaster and that only returns existing values but EPMDocumentMasterIdentity does return the new target value prior to the change taking place.  Thank you for that.

 

The problem I'm still having is that EPMDocumentMasterIdentity only returns some of the new values for each listener call.  When changing both number and cad name, two separate loops are executed, and as far as I can tell there is no way in the first loop to tell what (if anything) will be changing in the second loop (or if there even will be a second loop).

 

If a user is attempting to change more than one thing, how do I validate all of the new values that were entered before any of them are changed?

 

TomU_0-1637081207481.png

 

Turning on trace logging for com.ptc.windchill.uwgm.cadx.request.AbstractUwgmRequestAdapter I can see all of the new values.  I'd like to have some way to retrieve this information from a supported class when the listener(s) fire off.

 

TomU_2-1637081422701.png

 

PRE_CHANGE_CAD_NAME

PRE_CHANGE_IDENTITY (1st loop)

- only the cad name change is visible in this first 'loop':

TomU_3-1637081502231.png

POST_CHANGE_IDENTITY

POST_CHANGE_CAD_NAME

 

PRE_CHANGE_IDENTITY (2nd loop)

- the remaining changes for name and number are shown in the second loop:

TomU_4-1637081680640.png

POST_CHANGE_IDENTITY

 

From the log information shown above, I can see no way to tell during a cad name change if number is going to also going to be changing.  Any ideas?

TomU23-Emerald IVAuthor
23-Emerald IV
November 16, 2021

After scouring the PTC knowledge base, it seems the only supported method for keeping these synchronized is to use a TransactionCommitListener.

https://www.ptc.com/en/support/article/CS45397