Links to multiple Input Document files in DynaForms

I’d like to share this great contribution sent by one of our community members. In this article you will find an easy way to upload documents and have them as links in Dynaforms

Overview
Input Documents can hold multiple files (unless the Input Document is uploaded through a file field in a DynaForm which is only displayed once).  The list of the Input Document files could be displayed in a grid, just creating a trigger an constructing the path for the attached documents

Creating the example

The following trigger is used to populate a grid named “DocumentListGrid” with a textbox field, in view mode, named “filename” and a link field named “url“.

$caseId = @@APPLICATION;

$query = "SELECT C.CON_ID AS url, C.CON_ID AS url2, C.CON_VALUE AS filename FROM APP_DOCUMENT AD, CONTENT C
WHERE AD.APP_UID='$caseId' AND AD.APP_DOC_TYPE='INPUT' AND AD.APP_DOC_STATUS='ACTIVE'
AND AD.APP_DOC_UID=C.CON_ID AND C.CON_CATEGORY='APP_DOC_FILENAME' AND C.CON_VALUE<>''";
$result = executeQuery($query);
if (is_array($result) and count($result) > 0) {
for ($i = 1; $i <= count($result); $i++){
$result[$i]['url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/sys' . @@SYS_SYS . '/' .
@@SYS_LANG . '/' . @@SYS_SKIN . '/cases/cases_ShowDocument?a=' . $result[$i]['url2'];
}
@=DocumentListGrid = $result;
}

Extracting the URL twice, inside the SQL (i.e. ‘url’ and ‘url2’), so it is possible to manipulate the $result variable when constructing the link.

The extract pulls out all input documents for the case and rebuilds the $result array by changing the $result{x}[‘url’] field. the @=DocumentListGrid variable is then automatically populated with the filename of the document as well as the correct url to open it.

Assign the trigger before the dynaform loads and execute a case; uploading two files:

UploadingDocumentsExample

Result will be the dynaform with the description of both documents and their respective link to download them.

AttachingDocumentsListed

 

Contributor: Ade Stevenson

Source: ProcessMaker Forum

About This Author

Customer & Partner Support Manager for Colosa Inc. and ProcessMaker.