Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Dynamically assigning document type variables to RenderPDFForm service


Level 2

I have a process that takes an xml input, parses it and gets the value from one of its tags. Later I want to feed this value to the next activity in the process that has RenderPDFForm service. The name of the 'Form' input to RenderPDFForm should be the value extracted from the previous process.

How can I do that ?

Any help would be greatly appreciated.



1 Reply


Level 2

I figured out a way to assign the form name dynamically. I added an activity with
'ExecuteScript' service and this activity extracts form name to be rendered from one of the
tags in the input xml document using xpath expression.
This activity composes the actual form name based on what is extracted.
Here is my code that is in ExecuteScript that populates the document object. The document
object in the code will be used in the next activity (RenderPDFForm) in the process as input.

import java.util.List;
import java.lang.String;
import java.util.Map;
import java.util.HashMap;
import java.io.File;
import com.adobe.idp.Document;
String formId = patExecContext.getProcessDataStringValue("/process_data/inputDoc/form/formHeader/formId");
String formName = "Applications/MyApplication10/1.0/Forms/" + formId;
File file = new File(formName);
Document doc = new Document(file,false);

Now my problem is that the process is failing trying to find the file. It is throwing FileNotFoundException.
How should I specify the file name so that the process finds it.I have made sure that the file actually exists in the location that is specified.