Affects Version/s: 22.214.171.124 DXP SP1
Fix Version/s: None
Liferay Forms provides the ability for a custom DDMStorageAdapter.save(DDMStorageAdapterSaveRequest) method to save submitted form data, which overrides the default behavior which is to save the data to the Liferay database. The problem is that the url contained within the DDMFormFieldValue JSON text is not populated in JSON when a document is selected after being newly uploaded to the document library.
1. Create a new module with a CustomStorageAdapter that looks like this and deploy the module to $LIFERAY_HOME/osgi/modules:
2. Click on "Content & Data -> Forms" in the Control Panel and create a form with a file upload field. Name the field "attachment".
3. Before hitting the Save button, click the "..." button at the top of the page and then click on "Settings".
4. Select "Custom" from the dropdown list for the custom storage option.
5. Disable the autosave.
6. Set the name of the form to be "MyForm"
7. Save the form.
8. Publish the form.
9. Add the Forms portlet to a portal page and select "MyForm" to be displayed.
10. Select a file with the file upload control
11. Upload a new PDF file to the document library
12. Select the file from the document library
13. Click on Save in order to submit the form
The console output from System.out.println contains a non-null/non-empty relative URL of the submitted file. This is the URL that makes it possible to download the file.
The console output from System.out.println contain a null/empty URL for the submitted file.
Note that when selecting an existing (previously uploaded) file with the document library file selection, the URL field will indeed be populated with a non-null/non-empty value.