Skip to main content
11-Garnet
Jun 19, 2025 7:48 AM UTC
Solved

How to listen to event while moving object from one container to another using move action?

hi @BjoernRueegg ,

 

I have use case while create Part need to move different folder i am using 

managerService.addEventListener(partListMoveListener, PersistenceManagerEvent.generateEventKey(PersistenceManagerEvent.POST_STORE));


//for move
wt.folder.FolderHelper.service.changeFolder((wt.folder.FolderEntry) part, folder);

but getting Error ""Cannot move XXXXX because Object "XXXXXX" must be assigned to a folder"". I checked target folder is coming with destination folder.

please help on that

 

Reference topic: https://community.ptc.com/t5/Windchill-Customization/How-to-listen-to-event-while-moving-object-from-one-container-to/m-p/876767#M1828 

17-Peridot
Jun 26, 2025 6:58 AM UTC

@AA_9841156 I haven't tried it while creating a new object. Have you turned the logger on? Perhaps you can't listen to the event since it is not a move while creating a new part. Also, you need to make sure that a later event won't override your made changes.

wt.services.verbose=true
wt.services.verboseEvents=true

Since it is a new WTPart it could be that you can set the context and folder within the NEW_VERSION  event. See also CS164007 

Just my thoughts.

11 replies

18-Opal
Jun 19, 2025 7:54 AM UTC

Hi @AA_9841156,

 

Is there any reason not to set the target folder using OIR?

Why do you want to use Listeners?

Translate
11-Garnet
Jun 19, 2025 8:21 AM UTC

Hi @TDT ,

 

Actually  i have to move part once created, to related service container . but for time being i just checked same container but different folder.

 

Translate
18-Opal
Jun 19, 2025 12:10 PM UTC

Hmmm,

I just wrote a listener to detect a move. Upon move I print a message to state what got moved and to where.

It's works as expected.

MS LOG reads:

 

2025-06-19 08:05:15,761 INFO [ajp-nio-127.0.0.1-8010-exec-7] wt.system.out wcadmin -
2025-06-19 08:05:15,761 INFO [ajp-nio-127.0.0.1-8010-exec-7] wt.system.out wcadmin - You just moved Document - 0000000028, Testing, A.2 to /Default/Testing/Testing. Now what?

 

And then I move it back to its original folder.

MS LOG now reads:

 

2025-06-19 08:45:23,460 INFO [ajp-nio-127.0.0.1-8010-exec-7] wt.system.out wcadmin -
2025-06-19 08:45:23,460 INFO [ajp-nio-127.0.0.1-8010-exec-7] wt.system.out wcadmin - You just moved Document - 0000000028, Testing, A.2 to /Default/Documents/Testing. Now what?

 

It works as expected. Not sure what you want to do upon move, you never stated that 🤷‍♂️, but the listener definitely works.

Translate
11-Garnet
Jun 20, 2025 4:28 AM UTC

Hi @d_graham @BjoernRueegg 

 

Actually my requirement is if Part or PartList created so as per OIR that object will be store mentioned folder as mentioned in OIR. once object  created I want to move that object to respective service container to different folder.

that use case i am trying with Listener POST_STORE event but not able to do it.

 

Translate
18-Opal
Jun 20, 2025 11:07 AM UTC

So, OIR has nothing to do with this.

 

You just want to move the part somewhere after it’s created. Very doable but how do you know which container/folder to move the part to? 🤷‍♂️


What’s the logic you are using to determine the new location?
 

Translate
17-Peridot
Jun 26, 2025 6:58 AM UTC

@AA_9841156 I haven't tried it while creating a new object. Have you turned the logger on? Perhaps you can't listen to the event since it is not a move while creating a new part. Also, you need to make sure that a later event won't override your made changes.

wt.services.verbose=true
wt.services.verboseEvents=true

Since it is a new WTPart it could be that you can set the context and folder within the NEW_VERSION  event. See also CS164007 

Just my thoughts.

Translate
11-Garnet
Jun 26, 2025 4:10 PM UTC

Thanks @BjoernRueegg  for sharing your thoughts and this thoughts hit the solution super.. 😊

Its working as per expectation.

Translate