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

Community email notifications are disrupted. While we are working to resolve, please check on your favorite boards regularly to keep up with your conversations and new topics.

Move files with an expression robot

Dobrisa
13-Aquamarine

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? 

1 ACCEPTED SOLUTION

Accepted Solutions

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());

  

View solution in original post

2 REPLIES 2

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());

  

Dobrisa
13-Aquamarine
(To:BjoernRueegg)

Thanks! That worked.

Top Tags