Expand my Community achievements bar.

SOLVED

Combining PDF Attachments with DDX, then send separately with Document of Record in AEM OSGi Workflow

Avatar

Level 4

I have a dynamic number of pdf attachments as input from an adaptive form, and would like to merge all attached pdfs into a single pdf using DDX, then have it send separately with the Document of Record with the Send Email step. However I encountered an issue with the Send Email step with the following: 

 

Caused by: com.adobe.granite.workflow.WorkflowException: GetPropertyValue failed as value corresponding to VARIABLE:attachments for type class java.lang.Object is NULL

 

 

The DDX is as follows:

 

<DDX xmlns="http://ns.adobe.com/DDX/1.0/"> 
    <PDF result="Attachments.pdf"> 
         <PDF source="fileAttachment"/> 
    </PDF> 
</DDX>

 

 

Input map for invoke ddx:

The "attachment" path matches the output attachment folder of the adaptive form

techddx_0-1600213093578.png

Output map:

The output document is saved into the "attachments" document variable

techddx_1-1600213301535.png

Send Email step with Document of Record and attachments document:

techddx_2-1600213476906.png

 

 I am unsure why the value for attachments is NULL. Any help on this is appreciated, thank you!

 

EDIT - testing workflowuser's process:

The following is the dynamic table with file attachments. The ordering is PDFs 1,2,3,4, but the resultant PDF from the process gives ordering 2,3,4,1. 

techddx_0-1600299274726.png

 

1 Accepted Solution

Avatar

Correct answer by
Level 9

please log a support ticket with Adobe if you are having problems with 20 or more attachments in the form

View solution in original post

59 Replies

Avatar

Employee Advisor

are the form attachments getting assembled into one pdf?

Avatar

Level 4
Hi workflowuser, yes, the goal is to assemble all form attachments into one pdf, then have it send as a separate attachment with the Document of Record.

Avatar

Level 9
For now remove the send email and check if the invoke ddx step is working

Avatar

Employee Advisor
i will have to look into it as to why it is not working. I have used custom osgi bundle which seems to work fine. If you are open to use the custom bundle to get unblocked I can send it to you. But we absolutely need to get it working using the workflow step

Avatar

Level 4
Somehow I wonder about the attachments coming from your AF. The DDX assembles 1 source from fileAttachment into the Attachments.pdf. According to the DDX reference manual the source is either a single document that you map or a list of documents. Looking at this I am not sure if your input map is correct. If it isn't and it cannot assemble the Attachments.pdf then that could explain your error. Test the Assember step on its own and see if you actually get a valid PDF result.

Avatar

Level 4
Hi Girish and Kosta, I tested the invoke ddx step by itself and it results in a failure. I suspect the issue is due to the input mapping as well. I made an ArrayList variable of type Document to hold the attachments, but the ArrayList/Document variable does not show in the Set Variable step. It does not show in the input mapping of invoke ddx either, as it only accepts a variable of type Document. FYI, this is on AEM version 6.5.4.

Avatar

Level 4
Hi workflowuser, i am open to using a custom osgi bundle, but would prefer to solve this with the out of the box features.

Avatar

Employee Advisor
ok, let me send you the custom bundle to get you unblocked. By the way the custom bundle uses the publicly documented API . I will send you the bundle by EoD today

Avatar

Employee Advisor

Deploy and start the custom bundle and do the following. in your workflow drop process step component.( this will replace the invoke DDX step) associate the process with Assemble Task Attachments. this code assembles the  PDF  attachments of the Adaptive Form and stores it in a file called assembled-pdf.pdf under the payload folder. Create a variable called assembledPDF of type Document. Use the Set Variable component to initialize the variable as shown in the screen shot . You can use this variable in your send email step

workflowuser_0-1600277927375.png

workflowuser_1-1600278092459.png

Let me know if you have trouble getting this to work

In the meantime, I will investigate why the invoke DDX step is not working

BTW the code also writes the assembledpdf to the folder of your aem installation

 

Avatar

Level 4
Hi workflowuser, I tested your process locally and it works great. Is it possible to reorder the attachments? I currently have a dynamic table where each row has an attach file button. The first row is static and the following rows can be added dynamically. In the resultant PDF from the process, the ordering of the attachments prioritizes the dynamic rows over the first static row, when it should be the first row then the dynamic rows. I will add a screenshot to my original post to explain better.

Avatar

Level 4
Hi workflowuser, instead of using file attachments in a table, i am using a single file attachment button that allows multiple files. However the same issue occurs where the ordering goes 2, 3, 4, 1. Is there a way to fix this issue?

Avatar

Level 9

Hmm

let me check and get back to you 

this will require custom code as the invoke ddx step may not be able to do the ordering that you want

Avatar

Level 9

Will your file names will always be the same?

either way this cannot be done without writing custom code 

you will have to create the ddx with the pdf source elements in the right order then use that ddx to assemble the documents

Avatar

Level 9

I recommend you to use a panel and in that panel let your users add the attachment. One file only

make that panel repeatable 

so when the user submits the form  grab the data.xml That holds your submitted data and iterate through the panels and create your ddx accordingly 

Avatar

Level 9

This document will help you get stated with creating your first OSGI bundle

https://docs.adobe.com/content/help/en/experience-manager-learn/forms/adaptive-forms/custom-process-...

you will need to familiarize your self with DDX for creating the bundle to accomplish your task

also take a look at the xml file in your payload folder in the crx

Avatar

Level 4
Hi Girish, thank you for all your help and advice. I will look into creating the bundle and post an update here.

Avatar

Level 9

Let us know if you have problems creating your own bundle

Ii could give you the ready to use bundle but would be better for you to try creating the bundle

i can definitely help you with the code

Avatar

Level 9

I have a solution. Let me test it a little more before Icanngive it to you 

Avatar

Employee Advisor

workflowuser_0-1600708540154.png

 

the new bundle can be downloaded from here

https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:63e0e5ce-9099-42ca-ac0d-d4f9f764d2dd

Sample form

https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:f389a099-be09-4c9d-a612-5bd2063076e2

In the process step we can specify the order in which you want the attachments to be assembled.In this screenshot attachment added to the field called idcard will be the first pdf followed by attachments added to the bankstatements which is a field in a table that can grow

Avatar

Level 4
Hi workflowuser, I tested the bundle and it works great! Is it possible to have another version of the bundle that doesn't generate the output pdf and ddx in the aem installation folder? Thank you!