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

Which event to listen for to catch a name change

SOLVED
Highlighted
Newbie

Which event to listen for to catch a name change

Hello!

I have a listener in Windchill and have figured out how to catch 2 of of 3 events when it comes to rename in Windchill 10 M030.

To catch a change of filename aka CADName I listen for:

EPMDocumentManagerEvent.PRE_CHANGE_CAD_NAME

To catch a change of NUMBER I listen for:

IdentityServiceEvent.PRE_CHANGE_IDENTITY

However to listen for a change of NAME I'm stuck.

Does anyone have an idea what to look for?

It looks as if I can obtain this using:

PersistenceManagerEvent.POST_STORE

But I believe this is a little late in the chain since I plan to stop the transaction if some criteria are met and that would probably result in a rollback.

Any help is appreciated!

Best regards,

Peter

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Which event to listen for to catch a name change

Hello!

Since no one seems to know I will answer this myself.

I have found out that I can listen for PersistenceManagerEvent.INSERT events and obtain the information I need according to below:

if (event instanceof PersistenceManagerEvent) {

PersistenceManagerEvent pme = (PersistenceManagerEvent) event;

Object target = pme.getEventTarget();

if (target instanceof IdentityChangeHistory) {

IdentityChangeHistory ich = (IdentityChangeHistory) target;

String attributeName = ich.getAttributeName();

if (attributeName.equals("name")) {

ObjectReference or = ich.getObject();

Persistable p = or.getObject();

if (p instanceof EPMDocumentMaster) {

EPMDocumentMaster master = (EPMDocumentMaster) p;

String newValue = ich.getNewValue();

String oldValue = ich.getOldValue();

}

}

}

}

It seems it is possible to check for number and filename using this event as well.

Cheers!

/Peter

2 REPLIES 2

Re: Which event to listen for to catch a name change

Hello!

Since no one seems to know I will answer this myself.

I have found out that I can listen for PersistenceManagerEvent.INSERT events and obtain the information I need according to below:

if (event instanceof PersistenceManagerEvent) {

PersistenceManagerEvent pme = (PersistenceManagerEvent) event;

Object target = pme.getEventTarget();

if (target instanceof IdentityChangeHistory) {

IdentityChangeHistory ich = (IdentityChangeHistory) target;

String attributeName = ich.getAttributeName();

if (attributeName.equals("name")) {

ObjectReference or = ich.getObject();

Persistable p = or.getObject();

if (p instanceof EPMDocumentMaster) {

EPMDocumentMaster master = (EPMDocumentMaster) p;

String newValue = ich.getNewValue();

String oldValue = ich.getOldValue();

}

}

}

}

It seems it is possible to check for number and filename using this event as well.

Cheers!

/Peter

Re: Which event to listen for to catch a name change

Thanks Peter really useful information.