Questions and discussion about using ProcessMaker: user interface, running cases & functionality
By khoer52
#784110
I'm trying to upload multiple document, so i add file control in a grid.
After submit the dynaform, it succed upload document. But next dynaform i want to show those documents again. But it show nothing. Even though, if the file control not inside a grid, it can show document that has been uploaded.
Selection_270.png
Dynaform after upload multiple document inside grid and outside grid
Selection_270.png (9.75 KiB) Viewed 4924 times
By carloscalacin
#784115
hi khoer52,
I resolved this with 2 triggers.
My english is not well but I will try to help you with an example.

I will use 2 tasks, task1 and task2, also I will use a grid called grid1 with a text called product and a file called file1, the first triggers will be export all grid name into a table called grind_info.
the table has 3 fields (caseNumber, fileName, fileLink)

first trigger must be in task1 after dynaform.
Code: Select all
$sCaseNumber = @@APPLICATION;
$query2 = "SELECT APP_NUMBER FROM application WHERE APP_UID ='$sCaseNumber '";
$result2 = executeQuery($query2);
$sNumber= $result2[1]['APP_NUMBER'];
$aGrid = @=grid1;

foreach ($aGrid as $row) {
	$product = $row['product_label'];
	$fileName= $row['file1_label'];
	$fileName = substr($fileName, 2, -2);
	$query3 = "SELECT CONCAT('../cases/cases_ShowDocument?a=', C.CON_ID) as url FROM app_document AD, content C WHERE AD.APP_UID = '$sNumeroCaso' AND AD.APP_DOC_TYPE='ATTACHED' 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 = '$adjuntarOferta' limit 1";
	$fileResult = executeQuery($query3);
	$fileLink = $fileResult[1][url];

	$query = "INSERT INTO grind_info(caseNumber, fileName, fileLink) VALUES ('$sNumber', '$fileName', '$fileLink')";

	
	$result = executeQuery($query);	
}
the second trigger must be in the task2 in before dynaform
Code: Select all
$sCaseNumber = @@APPLICATION;
$query2 = "SELECT APP_NUMBER FROM application WHERE APP_UID ='$sCaseNumber '";
$result2 = executeQuery($query2);
$sNumber= $result2[1]['APP_NUMBER'];
$query = "select gi.fileName, gi.fileLink from grind_info gi where gi.caseNumber= $sNumber";
$result = executeQuery($query);

if (is_array($result) and count($result) > 0) {
   @=grid1= $result;
}

This work for my and I hope that works for you.
By khoer52
#784143
My English is not well too but i'm happy you do understand what i'm trying to do.
:)

In your code, you use INSERT INTO. Is that mean the table you said is in the database? So i have to create new table in my database. I have not try that. But i try your first query like this.
Code: Select all
//cari id dokumen lampiran
$caseId=@@APPLICATION;
$query = "SELECT C.CON_ID AS fileId, C.CON_VALUE AS titleFile, 
   CONCAT('../cases/cases_ShowDocument?a=', C.CON_ID) AS file, 
   AD.APP_DOC_CREATE_DATE AS dateUploaded, AD.USR_UID AS uploaderId 
   FROM APP_DOCUMENT AD, CONTENT C
   WHERE AD.APP_UID='$caseId' 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<>'' AND AD.APP_DOC_TYPE='ATTACHED' ORDER BY dateUploaded desc";
$files = executeQuery($query);

@=daftarLampiran=$files[1];
And i use jQuery to show the link.
Code: Select all
$(document).ready(function () {
   var totalRows = getFieldById("daftarLampiran").gridtable.length;
   for (var row = 1; row<=totalRows; row++){
      $("#form\\[daftarLampiran\\]\\["+row+"\\]\\[dokumen\\]").attr("href", $("#form\\[daftarLampiran\\]\\["+row+"\\]\\[file\\]").val());
      $("#form\\[daftarLampiran\\]\\["+row+"\\]\\[dokumen\\]").text($("#form\\[daftarLampiran\\]\\["+row+"\\]\\[titleFile\\]").val());
   }
});
It works for me, and i hope it can helps someone else
By carloscalacin
#784157
Excellent that you find another way to do it.

I have a question, the files keep the same order in the grid?
For example:
I have 2 grid lines in the first task,
line1 I upload a file called file1
Line2 I upload a file called file2.
In the second task
Line1 sometimes display file2 or file1
Line2 somestimes display file1 or file2
By waikok
#784278
Hi khoer52,

I trying out your code however, I am not able to get it work. Are you able to help to provide more detail steps?
This is what I had tried:
1. Created Task1 and Task2
2. Created Trigger1 based on your first query code.
3. Created one grid variable called 'daftarLampiran'
3. Create Form1 and Form2. Form1 has grid object and in grid object I have textbox and file object.
4. Add 'daftarLampiran' to this grid
5.Added Form1 and Trigger1 to Task1
6 Something similar in Task2 except view mode
7. added your 2nd sample script to Task2 javascript
8. however, when I try to run, nothing is populated into the grid in Task2 .

any idea where went wrong?

Thanks.

Hi Buddy, Although, there are lots of solution yo[…]

🚀 Kaçırmayın! Dinamik kripto endüstris[…]

Are you thinking of joining the exciting world of […]

I started betting on sports at https://ggbet.co.uk[…]