3 Replies Latest reply on Jan 4, 2013 7:17 AM by jnorris

    notifications with attachments

    jnorris Newbie

      I have a use case where I want to add an attachment to a user task, complete the task and then send an email with the attachment.  Does anyone have a solution for this?  I looked at the EmailWorkItemHandler and there is no support for attachments. 


      Also in another use case how would an attachment for one user task get passed to another user task?




        • 1. Re: notifications with attachments
          jnorris Newbie

          I see from this previous post:  https://community.jboss.org/thread/205775 that attachments for email are not supported.  Does anyone have a custom solution they could share?




          • 2. Re: notifications with attachments
            Thomas Setiabudi Expert

            Hi jnorris,


            Human Task by default support attachment,


            here you go


            Attachment attachment = new Attachment();
              attachment.setAttachedAt(new java.util.Date());
              attachment.setAttachedBy(new User(userLogon));
             // file is a byte[] variable
              Content content = new Content(file);
             TaskClient taskClient = getTaskClient();
              BlockingAddAttachmentResponseHandler responseHandler = new BlockingAddAttachmentResponseHandler();
              taskClient.addAttachment(taskId, attachment, content, responseHandler);
              Map<String, Long> result = new HashMap<String, Long>(2);
              result.put("attachmentId", responseHandler.getAttachmentId());
              result.put("contentId", responseHandler.getContentId());


            If you use persistence, you will be able to see the attached file in Attachment table



            Thomas Setiabudi

            • 3. Re: notifications with attachments
              jnorris Newbie

              Thanks for the reply Thomas.  Is the result map you show the content data in the task complete method?  How would the id's be used with the jbpm api to have the attachment passed to the next task in a chain of tasks?  We are using persistence but have no direct access to the tables at this point.