Skip to main content
1-Visitor
January 23, 2018
Solved

Move files with an expression robot

  • January 23, 2018
  • 1 reply
  • 2147 views

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? 

Best answer by BjoernRueegg

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

  

1 reply

17-Peridot
January 24, 2018

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

  

Dobrisa1-VisitorAuthor
1-Visitor
January 24, 2018

Thanks! That worked.