16 Replies Latest reply on Feb 6, 2010 3:05 AM by Balaji Gurumurthy

    Handling attachments of the form

      Hello All

      I have a scenario where the pdf form has to be emailed to a particular person along with its attachments. I know how to get the pdf form from the process flow (I can use render pdf service).

      But how can you get the attachments associated with that pdf form ? so that along with the pdf i can attach the files which are attached to the form.

      Thanks
      Deepak
        • 1. Re: Handling attachments of the form
          deepusrp Level 1

          Hello,

           

          Anybody knows how to do it?

           

          My requirement is:

           

          A user attaches some image files in the workspace while filling the form.  I need to attach these image files when i'm emailing the filled pdf form as an attachment to a user.

           

          How can i do that?  Is it possible?

           

          Thanks in advance

          Deepak

          • 2. Re: Handling attachments of the form
            pguerett Level 6

            Yes it is possible. You would have to get the images out of the task (in the user task, under Attachments and Notes, there is an Output Attachments area that needs a list of documents to hold the inbound attachments). Now that you have the attachments in a list var you can use the Forms RenderPDF service to Render the PDF and add the attachments to the PDF. Note that the RenderpDF service expects the attachments in a map and not a list so you will have to change it from one to the other.

             

            Paul

            • 3. Re: Handling attachments of the form
              deepusrp Level 1

              Hello pgurett,

               

              Thanks for your valuable comments.  But still the functionality is not working.

               

              Let me explaing the steps i followed:

               

              1.  Created 2 process variables

                   OtherAttachmentsList      - Type list - subtype Document

                   OtherAttachmentsMap     - Type map - subtype Document

               

              2.  On the Assign task, under Attachments and Notes, I have set the output attachment variable to OtherAttachmentList

               

              3.  Before renderPDF, on the Setvalue control i have assigned OtherAttachmentsMap = OtherAttachmentsList.

                   You have told to convert from list to map.  How i have to do?  I'm simply assigning as above.

               

              4.  On the RenderPDF form control, under attachments, i have set the variable as OtherAttachmentsMap

               

              Now the process is getting stalled at the RenderPDF form step and the exception it is giving is:

               

              java.lang.ClassCastException: java.lang.Integer
              at com.adobe.formServer.docservice.FormsDocService.appendAttachmentsToInputData(FormsDocServ ice.java:724)
              at com.adobe.formServer.docservice.FormsDocService.renderPDFForm(FormsDocService.java:108)
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at com.adobe.idp.dsc.component.impl.DefaultPOJOInvokerImpl.invoke(DefaultPOJOInvokerImpl.jav a:181)
              at com.adobe.idp.dsc.interceptor.impl.InvocationInterceptor.intercept(InvocationInterceptor. java:134)
              at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptor ChainImpl.java:44)
              at com.adobe.idp.dsc.transaction.interceptor.TransactionInterceptor$1.doInTransaction(Transa ctionInterceptor.java:74)
              at com.adobe.idp.dsc.transaction.impl.ejb.adapter.EjbTransactionBMTAdapterBean.doRequiresNew (EjbTransactionBMTAdapterBean.java:218)
              at sun.reflect.GeneratedMethodAccessor334.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
              at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionConta iner.java:214)
              at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionI nterceptor.java:149)
              at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor. java:54)
              at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
              at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:1 58)
              at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
              at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstance Interceptor.java:154)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
              at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor. java:122)
              at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
              at org.jboss.ejb.Container.invoke(Container.java:873)
              at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:415)
              at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:88)
              at $Proxy164.doRequiresNew(Unknown Source)
              at com.adobe.idp.dsc.transaction.impl.ejb.EjbTransactionProvider.execute(EjbTransactionProvi der.java:133)
              at com.adobe.idp.dsc.transaction.interceptor.TransactionInterceptor.intercept(TransactionInt erceptor.java:72)
              at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptor ChainImpl.java:44)
              at com.adobe.idp.dsc.interceptor.impl.InvalidStateInterceptor.intercept(InvalidStateIntercep tor.java:37)
              at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptor ChainImpl.java:44)
              at com.adobe.idp.dsc.interceptor.impl.AuthorizationInterceptor.intercept(AuthorizationInterc eptor.java:80)
              at com.adobe.idp.dsc.interceptor.impl.RequestInterceptorChainImpl.proceed(RequestInterceptor ChainImpl.java:44)
              at com.adobe.idp.dsc.engine.impl.ServiceEngineImpl.invoke(ServiceEngineImpl.java:113)
              at com.adobe.idp.dsc.routing.Router.routeRequest(Router.java:102)
              at com.adobe.idp.dsc.provider.impl.base.AbstractMessageReceiver.routeMessage(AbstractMessage Receiver.java:88)
              at com.adobe.idp.dsc.provider.impl.vm.VMMessageDispatcher.doSend(VMMessageDispatcher.java:21 0)
              at com.adobe.idp.dsc.provider.impl.base.AbstractMessageDispatcher.send(AbstractMessageDispat cher.java:57)
              at com.adobe.idp.dsc.clientsdk.ServiceClient.invoke(ServiceClient.java:208)
              at com.adobe.workflow.engine.PEUtil.invokeAction(PEUtil.java:553)
              at com.adobe.workflow.engine.ProcessEngineBMTBean.continueBranchAtAction(ProcessEngineBMTBea n.java:2863)
              at com.adobe.workflow.engine.ProcessEngineBMTBean.asyncContinueBranchCommand(ProcessEngineBM TBean.java:2392)
              at sun.reflect.GeneratedMethodAccessor935.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
              at org.jboss.ejb.StatelessSessionContainer$ContainerInterceptor.invoke(StatelessSessionConta iner.java:214)
              at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionI nterceptor.java:149)
              at org.jboss.webservice.server.ServiceEndpointInterceptor.invoke(ServiceEndpointInterceptor. java:54)
              at org.jboss.ejb.plugins.CallValidationInterceptor.invoke(CallValidationInterceptor.java:48)
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
              at org.jboss.ejb.plugins.AbstractTxInterceptorBMT.invokeNext(AbstractTxInterceptorBMT.java:1 58)
              at org.jboss.ejb.plugins.TxInterceptorBMT.invoke(TxInterceptorBMT.java:62)
              at org.jboss.ejb.plugins.StatelessSessionInstanceInterceptor.invoke(StatelessSessionInstance Interceptor.java:154)
              at org.jboss.ejb.plugins.SecurityInterceptor.invoke(SecurityInterceptor.java:153)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
              at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor. java:122)
              at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:624)
              at org.jboss.ejb.Container.invoke(Container.java:873)
              at org.jboss.ejb.plugins.local.BaseLocalProxyFactory.invoke(BaseLocalProxyFactory.java:415)
              at org.jboss.ejb.plugins.local.StatelessSessionProxy.invoke(StatelessSessionProxy.java:88)
              at $Proxy196.asyncContinueBranchCommand(Unknown Source)
              at com.adobe.workflow.engine.ProcessCommandControllerBean.doOnMessage(ProcessCommandControll erBean.java:133)
              at com.adobe.workflow.engine.ProcessCommandControllerBean.onMessage(ProcessCommandController Bean.java:94)
              at sun.reflect.GeneratedMethodAccessor759.invoke(Unknown Source)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:585)
              at org.jboss.invocation.Invocation.performCall(Invocation.java:345)
              at org.jboss.ejb.MessageDrivenContainer$ContainerInterceptor.invoke(MessageDrivenContainer.j ava:475)
              at org.jboss.resource.connectionmanager.CachedConnectionInterceptor.invoke(CachedConnectionI nterceptor.java:149)
              at org.jboss.ejb.plugins.MessageDrivenInstanceInterceptor.invoke(MessageDrivenInstanceInterc eptor.java:101)
              at org.jboss.ejb.plugins.AbstractTxInterceptor.invokeNext(AbstractTxInterceptor.java:106)
              at org.jboss.ejb.plugins.TxInterceptorCMT.runWithTransactions(TxInterceptorCMT.java:335)
              at org.jboss.ejb.plugins.TxInterceptorCMT.invoke(TxInterceptorCMT.java:166)
              at org.jboss.ejb.plugins.RunAsSecurityInterceptor.invoke(RunAsSecurityInterceptor.java:94)
              at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:192)
              at org.jboss.ejb.MessageDrivenContainer.internalInvoke(MessageDrivenContainer.java:389)
              at org.jboss.ejb.Container.invoke(Container.java:873)
              at org.jboss.ejb.plugins.jms.JMSContainerInvoker.invoke(JMSContainerInvoker.java:1077)
              at org.jboss.ejb.plugins.jms.JMSContainerInvoker$MessageListenerImpl.onMessage(JMSContainerI nvoker.java:1379)
              at org.jboss.jms.asf.StdServerSession.onMessage(StdServerSession.java:256)
              at org.jboss.mq.SpyMessageConsumer.sessionConsumerProcessMessage(SpyMessageConsumer.java:904 )
              at org.jboss.mq.SpyMessageConsumer.addMessage(SpyMessageConsumer.java:160)
              at org.jboss.mq.SpySession.run(SpySession.java:333)
              at org.jboss.jms.asf.StdServerSession.run(StdServerSession.java:180)
              at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(PooledExecutor.java:743)
              at java.lang.Thread.run(Thread.java:595)\

               

               

              What could be the problem?

               

              Thanks

              Deepak

              • 4. Re: Handling attachments of the form
                pguerett Level 6

                You cannot simply assign a list var to a map var. You will have to iterate through each item in the list and assign it to the map var.

                • 5. Re: Handling attachments of the form
                  deepusrp Level 1

                  Hello pguerett,

                   

                  Right now I have implemented it for one attachment.

                   

                  Let me explaing the steps i followed:

                   

                  1.  Created 2 process variables

                       OtherAttachmentsList      - Type list - subtype Document

                       OtherAttachmentsMap     - Type map - subtype Document

                   

                  2.  On the Assign task, under Attachments and Notes, I have set the output attachment variable to OtherAttachmentList

                   

                  3.  Before renderPDF, on the Setvalue control i have assigned OtherAttachmentsMap = OtherAttachmentsList.

                       I have done as you have instructed. (using docAttach, getting filename ...)

                   

                  4.  On the SendWithMapofDocuments control, under attachments, i have set the attachment variable as OtherAttachmentsMap

                   

                  i'm doing like this:

                   

                  /process_data/@docAttach =   /process_data/list[1] --------------- docAttach is a varibale of type document

                  /process_data/@docName =  getDocAttribute(/process_data/@docAttach, "wsfilename")  -------- docName is of type string

                  /process_data/@docDesc = getDocAttribute(/process_data/@docAttach, "wsdescription")  --- docDesc is of type string

                   

                  ********Assign it to Map:************

                   

                  /process_data/mapDoc[@id=/process_data/@docName] = /process_data/@docAttach --- mapDoc is a map subtype document

                   

                  Now my problem is, I'm getting attachment on the email but the content is not proper.  Can there be any problem with the mime type or the encoding standards?  Or am i missing any configurations?

                   

                  I even tried with the loop also... it is working fine but the problem is none of the files would be in proper format.  filename, extention, everything will be similar to the docs that i attach but when tried to open it is failing.  Please guide me, where is it getting...

                   

                  Deepak

                  • 6. Re: Handling attachments of the form
                    deepusrp Level 1

                    Hi..

                     

                    Got it!!!

                     

                    While testing something i had changed subtype of map to string later i forgot to change back to document...

                     

                    Deepak

                    • 7. Re: Handling attachments of the form
                      pguerett Level 6

                      In the document variables there are attributes that can be set for mimetype etc. .....If you do a record/playback and look at the document you can get the attribute value that needs to be set.

                       

                      Paul

                      • 8. Re: Handling attachments of the form
                        deepusrp Level 1

                        Hi..

                         

                        I have got my issue resolved....

                         

                        Thanks for all the members for their valuable suggetions...

                         

                        Deepak

                        • 9. Re: Handling attachments of the form
                          waqas.rehman

                          Kindly mark the discussion as Answered.

                           

                          Regards,

                          Waqas

                          • 10. Re: Handling attachments of the form
                            deepusrp Level 1

                            how can i do that, i'm not finiding any way to that...!!

                            • 11. Re: Handling attachments of the form
                              HowardTreisman Level 1

                              Hi

                              A simpler way to convert a list to a map, or a map to a list, and various other operations, is to use our CollectionUtils component.

                              Here: http://avoka.dnsalias.com/confluence/display/Public/Collection+Utilities+DSC

                              Download here: http://www.avoka.com/avoka/escomponents.shtml


                              Howard

                              • 12. Re: Handling attachments of the form
                                Balaji Gurumurthy Level 1

                                Hi

                                 

                                Im facing the same issue. It would be nice if you provide the code for looping through the attachments and assigning from List to Map variable.

                                 

                                Thanks,

                                Balaji

                                • 13. Re: Handling attachments of the form
                                  Balaji Gurumurthy Level 1

                                  hi all.

                                       I have tried more than a couple of times the below, i could execute the code with no error but unable to see any attachments ..

                                  Can u pls go thru and update ..

                                   

                                  //import the classes that the script references
                                  import java.util.List;
                                  import java.lang.String;
                                  import java.util.Map;
                                  import java.util.HashMap;

                                  import java.io.*;
                                  import java.lang.*;
                                  import java.util.*;

                                  import com.sun.xml.internal.txw2.Document;

                                  try
                                  {
                                  List attachmentListDoc = patExecContext.getProcessDataListValue("/process_data/inputattachments");

                                  Map attachmentMapDoc = new HashMap();

                                  for (int i = 0; i < attachmentListDoc.size(); i++)
                                  {
                                    //String currentFileName = (String)attachmentListDoc.get(i);
                                    Document doc = (Document)attachmentMapDoc.get(i);
                                    attachmentMapDoc.put(i, doc);
                                    //attachmentMapDoc.put(i, attachmentListDoc.get(i));
                                  }

                                  patExecContext.setProcessDataMapValue("/process_data/attachmentsmap",attachmentMapDoc);
                                  }
                                  catch (Exception e)
                                  {
                                  e.printStackTrace();
                                  }

                                  thanx

                                  Balaji

                                  • 14. Re: Handling attachments of the form
                                    Jasmin Charbonneau Level 4

                                    What do you get for attachmentMapDoc.size()?

                                     

                                    Does it populate the map properly?

                                     

                                    Jasmin

                                    • 15. Re: Handling attachments of the form
                                      Scott Brodersen Adobe Employee

                                      there's a mistake in the line

                                       

                                      patExecContext.setProcessDataMapValue("/process_data/attachmentsmap",attachment MapDoc);
                                      }

                                       

                                      You have a space in the name of the map variable.

                                       

                                      Just out of curiousity, where does e.printStackTrace() get displayed? It might be more useful to, in your catch, save the stack trace to a string variable.

                                       


                                      Execute Script is very useful, but also very difficult to debug.

                                      scott

                                      • 16. Re: Handling attachments of the form
                                        Balaji Gurumurthy Level 1

                                        No the above code did not work out ..

                                        I made it work using Iterator - very small code below .. jus for ur reference

                                         

                                        import java.util.List;
                                        import java.util.HashMap;
                                        import java.util.Map;
                                        import java.util.Iterator;
                                        import com.adobe.idp.Document;

                                        List attachmentListDoc = patExecContext.getProcessDataListValue("/process_data/inputattachments");

                                        Map attachmentMapDoc = new HashMap();

                                        Iterator it = attachmentListDoc.iterator();

                                        while (it.hasNext()) {

                                        Document attDoc = (Document) it.next();
                                        String name = (String) attDoc.getAttribute("wsfilename");

                                        attachmentMapDoc.put(name,attDoc);
                                        }

                                        patExecContext.setProcessDataMapValue("/process_data/attachmentsmap",attachmentMapDoc);

                                        This converts List to Map successfully. This code helps whoever is in need of.

                                         

                                        thanx

                                        Balaji