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

Community Tip - Help us improve the PTC Community by taking this short Community Survey! X

Translate the entire conversation x

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

AA_9841156
11-Garnet

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 

ACCEPTED SOLUTION

Accepted Solutions

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

View solution in original post

11 REPLIES 11
TDT
15-Moonstone
15-Moonstone
(To:AA_9841156)

Hi @AA_9841156,

 

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

Why do you want to use Listeners?

AA_9841156
11-Garnet
(To:TDT)

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.

 

Fadel
22-Sapphire III
(To:TDT)

The OIR is working only within same context , if object need to be moved to another prod/Library OIR won't help 

Fede

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.

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.

 

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?
 

I have this working.

My listener will put the WTPart in a folder upon creating the part.

Note the UI has the location set to a folder named Documents.

My listener however will make sure the part is in a folder named Parts during the creation process.

d_graham_0-1750440426924.png

 

Upon creation we can see the part in in the Parts folder.

d_graham_1-1750440664877.png

 

@AA_9841156 you still have not responded with the logic to determine which Container/Folder you are using the determine where the part should be located but rest assured it is doable.

 

Hi @d_graham ,

 

Actually in our System we have Service container for all container and having folder template as well .So when part is created i am trying to getting container for Part and find related Service container and then desired folder wherever i want.

that is not big deal .

What ever you did i think it will work for me could please share your code in ZIP file here.

Hi @d_graham ,

 

Please share your working code 

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

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

Its working as per expectation.

Announcements
Top Tags