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

Avatar

Avatar

techddx

Avatar

techddx

techddx

15-09-2020

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

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

23-09-2020

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

Answers (19)

Answers (19)

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

23-09-2020

Did you enable the log for the bundle?

check the logs it should give you more information 

Are these attachments all pdf files?

Hi Girish, yes all attachments are pdf

Here is a portion of the Data.xml after form submission:

 

 

 

<?xml version="1.0" encoding="UTF-8"?>
<afData>
    <afUnboundData>
        <data>
            <attachment1>
                <fileAttachment>1.pdf</fileAttachment>
            </attachment1>
            <attachment2>
                <fileAttachment>2.pdf</fileAttachment>
            </attachment2>
            <attachment3>
                <fileAttachment>3.pdf</fileAttachment>
            </attachment3>
            <attachment4>
                <fileAttachment>4.pdf</fileAttachment>
            </attachment4>
            <attachment5>
                <fileAttachment>5.pdf</fileAttachment>
            </attachment5>
            <attachment6>
                <fileAttachment>6.pdf</fileAttachment>
            </attachment6>
            <attachment7>
                <fileAttachment>7.pdf</fileAttachment>
            </attachment7>
            <attachment8>
                <fileAttachment>8.pdf</fileAttachment>
            </attachment8>
            <attachment9>
                <fileAttachment>9.pdf</fileAttachment>
            </attachment9>
            <attachment10>
                <fileAttachment>10.pdf</fileAttachment>
            </attachment10>
            <attachment11>
                <fileAttachment>11.pdf</fileAttachment>
            </attachment11>
            <attachment12>
                <fileAttachment>12.pdf</fileAttachment>
            </attachment12>
            <attachment13>
                <fileAttachment>13.pdf</fileAttachment>
            </attachment13>
            <attachment14>
                <fileAttachment>14.pdf</fileAttachment>
            </attachment14>
            <attachment15>
                <fileAttachment>15.pdf</fileAttachment>
            </attachment15>
            <attachment16>
                <fileAttachment>16.pdf</fileAttachment>
            </attachment16>
            <attachment17>
                <fileAttachment>17.pdf</fileAttachment>
            </attachment17>
            <attachment18>
                <fileAttachment>18.pdf</fileAttachment>
            </attachment18>
            <attachment19>
                <fileAttachment>19.pdf</fileAttachment>
            </attachment19>
            <attachment20>
                <fileAttachment>20.pdf</fileAttachment>
            </attachment20>
        </data>
    </afUnboundData>
    <afBoundData>
        <formData xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
            <processingInfo>
                <contractor>123</contractor>

 

 

All 20 attachments appear in the Data.xml, but the pdf is not assembled. The same problem happens with the repeating bankstatement panels in the bundle

 

You will need to change the parameter in the workflow step to reflect your attachment element

I have changed the arguments, and i still get the issue. It works when there are 18 attachment elements, but not when there are more.

techddx_0-1600904073390.png

The same problem happens in the repeating bankstatements panel. It works when there are less than 20 attachments

techddx_0-1600904263431.png

 

 

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

22-09-2020

Avatar

Avatar

workflowuser

Employee

Avatar

workflowuser

Employee

workflowuser
Employee

22-09-2020

your Data.xml should look something like this. It should have fileAttachment elements in it

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<afData>
<afUnboundData>
<data>
<tableItem11>Testing</tableItem11>
<telephonebill>
<fileAttachment>aa.png</fileAttachment>
</telephonebill>
<Row2>
<bankstatements>
<fileAttachment>adls.png</fileAttachment>
</bankstatements>
</Row2>
<idcard>
<fileAttachment>etrade.PNG</fileAttachment>
</idcard>
</data>
</afUnboundData>
<afBoundData>
<data xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/"/>
</afBoundData>
<afSubmissionInfo>
<computedMetaInfo/>
<stateOverrides/>
<signers/>
<afPath>/content/dam/formsanddocuments/assembleattachments</afPath>
<afSubmissionTime>20200920124211</afSubmissionTime>
</afSubmissionInfo>
</afData>

Avatar

Avatar

workflowuser

Employee

Avatar

workflowuser

Employee

workflowuser
Employee

22-09-2020

just double click on the Data,xml file

workflowuser_0-1600803752807.png

 

Avatar

Avatar

workflowuser

Employee

Avatar

workflowuser

Employee

workflowuser
Employee

22-09-2020

in your crx go to 

/var/fd/dashboard/payload/server0/<latest Date>/<mostrecentfolder>/

 

Avatar

Avatar

workflowuser

Employee

Avatar

workflowuser

Employee

workflowuser
Employee

21-09-2020

here is the updated bundle

https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:a9005085-7f50-4876-af8a-49a25c81b69e

I also removed the system.out.println  statements and moved them to log.debug. If you want to see the logs you can enable debug logs for this bundle

This is perfect, thank you!
Hi workflowuser, I think i may have found a bug. When you use an xml schema as the adaptive form model, the repeating panel method to add attachments generates an empty ddx file. Using a single file attachment button still works however.
can you paste the Data.xml contents from your workflow payload path after the form is submitted.
Sorry, how do you access the Data.xml after form submission? Is it through the CRX?
<?xml version="1.0" encoding="UTF-8"?> <afData> <afUnboundData> <data/> </afUnboundData> <afBoundData> <formData xmlns:xfa="http://www.xfa.org/schema/xfa-data/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <processingInfo> <contractor/> <contractorEmail/> <contractAgency/> <contractAgencyEmail/> </processingInfo> <stdAgreementDetails> <scoID/> <agreementNumber/> <purchaseAuthNumber/> <startDate/> <endDate/> <maxAmount/> <exemption/> </stdAgreementDetails> <contractorInfo> <contractorName/> <printedName/> <contractorTitle/> <contractorBusinessAddr/> <city/> <state/> <zip/> </contractorInfo> <contractAgencyInfo> <contractAgencyName/> <printedName2/> <agencyNameTitle/> <contractAgencyAddress/> <contractCity/> <contractState/> <contractZip/> </contractAgencyInfo> <exhibitsTable> <Row1> <ExhibitA/> <TitleA/> <PageA/> </Row1> <Row2> <ExhibitB/> <TitleB/> <PageB/> </Row2> <Row3> <ExhibitC/> <TitleC/> <PageC/> </Row3> <Row4> <ExhibitD/> <TitleD/> <PageD/> </Row4> </exhibitsTable> </formData> </afBoundData> <afSubmissionInfo> <computedMetaInfo/> <stateOverrides/> <signers/> <afPath>/content/dam/formsanddocuments/assembleattachmentsoriginalwithschema</afPath> <afSubmissionTime>20200922121748</afSubmissionTime> </afSubmissionInfo> </afData>

and fyi, the attachments are all in the attachments folder in the payload

in the Data.xml, I do not see any fileattachment nodes. where are the attachments?
Hi workflowuser, is there a cap on the number of attachments? I am testing the bank statements repeating panel. When i attach 20 attachments, the ddx is no longer generated.

Avatar

Avatar

workflowuser

Employee

Avatar

workflowuser

Employee

workflowuser
Employee

21-09-2020

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

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

20-09-2020

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

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

18-09-2020

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

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

17-09-2020

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

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

17-09-2020

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

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

17-09-2020

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

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

16-09-2020

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

Avatar

workflowuser

Employee

Avatar

workflowuser

Employee

workflowuser
Employee

16-09-2020

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

Avatar

workflowuser

Employee

Avatar

workflowuser

Employee

workflowuser
Employee

15-09-2020

are the form attachments getting assembled into one pdf?

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.
For now remove the send email and check if the invoke ddx step is working
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
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.
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.
Hi workflowuser, i am open to using a custom osgi bundle, but would prefer to solve this with the out of the box features.
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

Avatar

workflowuser

Employee

Avatar

workflowuser

Employee

workflowuser
Employee

07-10-2020

Here is the latest bundle

https://documentcloud.adobe.com/link/track?uri=urn:aaid:scds:US:6c353e00-1139-48c6-b8b3-5bd4abda5fd5

I have increased the size of my query to 100

Your workflow step should look like this

workflowuser_0-1602102827925.png

 

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

07-10-2020

I have also added bookmarks to the assembled pdf 

open the assembled pdf using Adobe reader and check the bookmarks 

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

06-10-2020

As a workaround have two repeating panel’s. The first panel you can allow users to add a maximum of say 12 attachments 

In the second panel they can add another 8 attachments and submit the form 

this is working for me 

Avatar

Avatar

GirishBedekar

Avatar

GirishBedekar

GirishBedekar

05-10-2020

Is that a common use case of attaching 20 pdf files?