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

Move files with an expression robot

SOLVED
Highlighted
Level 8

Move files with an expression robot

We have a workflow for submitting a file to a library. As part of that workflow, once an EPMDocument is approved, we want to move it to a specific folder. There's sample code listed on the support page that (after correcting typos) doesn't work. Instead, it comes up with a "Context not found: "Windchill PDM"" error.

I tried changing the folder path in place of the default "System" but that doesn't change anything. 

Where should I look to next? What am I missing? 

 

// Check if a PBO has been assigned to the process
 if (primaryBusinessObject !=null) {
try {
 wt.folder.Folder f = wt.folder.FolderHelper.service.getFolder( "/System");
 //move the PBO to the '/System' folder
wt.folder.FolderHelper.service.changeFolder((wt.folder.FolderEntry )primaryBusinessObject, f );
 }
catch ( wt.util.WTException wex ) {
 System.out.println( "Cannot move "+ primaryBusinessObject.getDisplayIdentifier( )+"because "+ wex.getLocalizedMessage( )}
}
 }
 else
 // if a PBO has not been assigned to the Process
 System.out.println( "Primary business object is NULL");

A version of this question can be that instead of moving the files, once a file has been classified in the library is there a way to replace instances of it through APIs with the library component and then just delete the original submission? 

Tags (1)
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Move files with an expression robot

Normally you should use the folder name "/Default/YOUR_FOLDER"

But when I look into your code, I guess you missed the last part of the call, where the context is evaluated. Otherwise the current library is not specified and the method tries to move the object to a system folder which is probably not existing.

 

wt.folder.Folder f = wt.folder.FolderHelper.service.getFolder("/Default/YOUR_FOLDER", ((wt.inf.container.WTContained)primaryBusinessObject).getContainerReference());

  

2 REPLIES 2

Re: Move files with an expression robot

Normally you should use the folder name "/Default/YOUR_FOLDER"

But when I look into your code, I guess you missed the last part of the call, where the context is evaluated. Otherwise the current library is not specified and the method tries to move the object to a system folder which is probably not existing.

 

wt.folder.Folder f = wt.folder.FolderHelper.service.getFolder("/Default/YOUR_FOLDER", ((wt.inf.container.WTContained)primaryBusinessObject).getContainerReference());

  

Re: Move files with an expression robot

Thanks! That worked.