Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By higgledy
#813522
I am following the example in this wiki page for display files in a grid. http://wiki.processmaker.com/3.1/File_control

I have it working as it is designed. How do I add custom file fields to the grid in the trigger? For instance, I created my own variable for file status, called fileStatus. How do I add fileStatus value to the $dataGrid[$i] in the trigger? Thanks.
User avatar
By amosbatto
#813531
Setting the value of a file in a trigger won't work. Instead, you have to write 'grid-variable_row-number_file-field-name' in the APP_DOCUMENT.APP_DOC_FIELDNAME field in the database for each file in the grid. See:
http://wiki.processmaker.com/3.0/File_c ... le_Storage

If the files aren't yet added to the case, then you need to first use PMFCopyDocumentCase(), PMFAddInputDocument() or PMFGenerateOutputDocument() to add the files to the case. Then, update to their records in the APP_DOCUMENT table.

Only MultipleFiles will display their files in a grid, so you also have to add the information about the file(s) in the grid. Here is an example of generating an Output Document and then transferring it to an Input Document which is capable of displaying in a grid. (Note: Output Documents can't be displayed in grids.)
Code: Select all
//set to UID of Output Document definition:
$outputDocId = '8517550915a9dfb3b997ef1008764338'; 
PMFGenerateOutputDocument($outputDocId);

$caseId = @@APPLICATION;
$sql = "SELECT * FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND 
   DOC_UID='$outputDocId' ORDER BY DOC_VERSION DESC";
$aFiles = executeQuery($sql);

if (empty($aFiles)) {
   throw new Exception("Unable to find new Output Document.");
}

//transfer from Output Document to Input Document:
$inputDocId = '8997436295a9e05059bb706026039756'; //set to ID of Input Document
$filename = $aFiles[1]['APP_DOC_FILENAME'].'.pdf'; //or '.doc'
$g = new G();
$filePath = PATH_DOCUMENT . $g->getPathFromUID($caseId) . PATH_SEP . "outdocs" . PATH_SEP .
      $aFiles[1]['APP_DOC_UID'] . '_' . $aFiles[1]['DOC_VERSION'] . '.pdf'; //or '.doc'

@@copiedFileId = PMFAddInputDocument($inputDocId, null, 1, 'INPUT', 'copied contract file', '',
   @@APPLICATION, @%INDEX, @@TASK, @@USER_LOGGED, 'file', $filePath);

$d = new AppDocument();
$aFileInfo = $d->Load(@@copiedFileId, 1);
//add file to the first row of the "clientGrid" variable in the "contractFile" field:
$aFileInfo['APP_DOC_FIELDNAME'] = 'clientGrid_1_contractFile'; 
$aFileInfo['APP_DOC_FILENAME']  = $filename; 
$d->update($aFileInfo);

@=clientGrid = array(
   1 => array( 
       'contractFile' => array(
          array(
             'appDocUid' => @@copiedFileId, 
             'name'      => $filename,
             'version'   => 1
          )
      ),
      'contractFile_label' => array( $filename )
   )
);
 
See:
http://wiki.processmaker.com/3.0/Intern ... Load.28.29
http://wiki.processmaker.com/3.0/Intern ... date.28.29

Here is the process if you want to test it:
(27.77 KiB) Downloaded 327 times
By higgledy
#813545
Thank you. But I am not sure your reply answers my question. Maybe I missed it. Maybe I did not explain my question.

I am developing a case management workflow. Each case contains 1 to several attached documents. For each document I need a "Document Status" with a value "Review Complete" or "Not Reviewed" I cannot use the APP_DOC_STATUS in APP_DOCUMENT because it's value is ACTIVE or DELETED. How do I associate a custom "Document Status" field for each attached document? How do I insert the initial value of "Not Assigned"? How do I query the db for the current value? How do I update the value when the document's status changes?

Please bear with me on my questions. I am trying to get funding to attend an online class. Hopefully my company will approve it this week.

Attached is a modified version of the process you sent me. Look at the form to see what I am trying to do. I hope this helps. Thanks.
Attachments
(28.86 KiB) Downloaded 305 times
User avatar
By amosbatto
#813595
If you want the users to upload the files to MultiFile controls placed in a grid, then you don't need to do any programming. Just create a grid with the following fields:
"caseFile" (MultiFile), "docStatus" (dropdown)

Set the "docStatus" dropdown to have the following options: "Not Assigned", "Review Complete" and "Not Reviewed".
Since "Not Assigned" is the first option in list, it will automatically be selected by default. You can also set the default value in the properties of the dropdown.

If you want to also store this information in a database table, then create a table with the following fields:
CASE_NUMBER (int), FILE_ID (vchar), FILE_VERSION (int), FILENAME (vchar), DOC_STATUS (vchar)

Then create a trigger that will write this information to the database after the DynaForm with the grid. See this code example:
viewtopic.php?f=44&t=730315#p813580
User avatar
By amosbatto
#826256
HeshanKaru1994 wrote: Wed Aug 28, 2019 11:30 pm Somehow uploaded files inside a grid gets cleared.(but not all of them)
That should not happen. What version of PM? Are you using MultipleFiles or Files in the grid?
User avatar
By amosbatto
#826272
The only way that I can imagine that happening is if you have multiple users logged into ProcessMaker from the same web browser or if you have two cases open in the same web browser.

If you have multiple users logged in or are trying to open multiple cases at the same time in your computer, then you need to use different web browsers (for example Firefox and Chrome) .
User avatar
By amosbatto
#826302
In your php.ini file, change to the following settings:
Code: Select all
max_file_uploads = 200
post_max_size = 100M 
upload_max_filesize = 100M
max_input_vars = 10000
memory_limit=512M
Does that solve the problem?
By HeshanKaru1994
#826303
This is an Enterprise Edition so have to check with the support team.But I found a temporary solution because after routing only the files gets cleared out.So after dynaform i'm saving the whole grid to a variable and after routing i'm reassigning to the previous variable.

In the rapidly evolving world of online sports be[…]

STEPN integrates social networking and games that […]

Cenforce 150 is a medication used to cope with a c[…]

What's SAP FICO?

Trustworthy and skill-building, each of these actu[…]