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

Need a method to add a workflow content file(s) to the PBO

Highlighted
Newbie

Need a method to add a workflow content file(s) to the PBO

I need a java method that takes the workflow content file(s) a user uploads and adds it to the PBO as an attachment. I have a situation where a particular role in a custom workflow does not have update authority to the Primary Business Object. What I need to do is provide the users in that role with a Content Workflow Task where they can upload a document to the workflow task. After they complete the task, I want to trigger a method robot. I want the robot to take that content file or files added to the workflow task and iterate the Primary Business Object, making the task content file(s) an attachment to the PBO. Does anyone know of any Out Of the Box java classes or methods that work with the content files of workflow tasks?
3 REPLIES 3
Highlighted

Copying workflow attachement to secondary attachments to PBO

Try the following code: public void uploadContent(WTReference self,WTObject primaryBusinessObject){ try{ ContentHolder cHolder=null; if(primaryBusinessObject instanceof Workable){ cHolder=(ContentHolder)getCheckedoutContentHolder((Workable)primaryBusinessObject); }else{ cHolder=(ContentHolder)primaryBusinessObject; } QueryResult result1=ContentHelper.service.getContentsByRole((ContentHolder)self.getObject(),ContentRoleType.SECONDARY); while(result1.hasMoreElements()){ ContentItem cItem=(ContentItem)result1.nextElement(); ContentHelper.service.copyContentItem((ContentHolder)cHolder,cItem); PersistenceHelper.manager.delete(cItem); } if(cHolder instanceof Workable){ WorkInProgressHelper.service.checkin((Workable)cHolder,"Check in in the workflow"); } }catch(Exception wte){ wte.printStackTrace(); } } If you have questions, you can reach me at 513-290-8664 or hjatla@datafrond.com Regards.
Highlighted

RE: Copying workflow attachement to secondary attachments to PBO

Thank you! We will give it a try.
Highlighted

RE: Copying workflow attachement to secondary attachments to PBO

Thanks Hema, I assume the 'self' is the self that is pre-declaired workflow variable. In testing, I found that I get a class cast exception on the query: QueryResult qResult = ContentHelper.service.getContentsByRole((ContentHolder)self.getObject, ContentRoleType.SECONDARY); Is the 'self' variable a WfProcess object?
Announcements