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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Which event to listen for to catch a name change

PeterWigren
12-Amethyst

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

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

3 REPLIES 3

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

KD
12-Amethyst
12-Amethyst
(To:PeterWigren)

Thanks Peter really useful information.

thank you for the information, can you share the full code plz?

 

Announcements


Top Tags