Skip to main content
11-Garnet
June 19, 2025
Solved

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

  • June 19, 2025
  • 3 replies
  • 1114 views

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 

Best answer by BjoernRueegg

@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.

3 replies

16-Pearl
June 19, 2025

Hi @AA_9841156,

 

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

Why do you want to use Listeners?

11-Garnet
June 19, 2025

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.

 

18-Opal
June 19, 2025

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.

11-Garnet
June 20, 2025

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.

 

18-Opal
June 20, 2025

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?
 

17-Peridot
June 26, 2025

@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-Garnet
June 26, 2025

Thanks @BjoernRueegg  for sharing your thoughts and this thoughts hit the solution super.. πŸ˜Š

Its working as per expectation.