Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
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?
Solved! Go to Solution.
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());
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());
Thanks! That worked.