Questions and discussion about using ProcessMaker: user interface, running cases & functionality

Moderator: amosbatto

#812538
I need to copy the uploaded documents from a subprocess to the main process.
Documents are uploaded by a user into the subprocess and then validated by a different user in the main process.
The user of MainProcess can only view and download the files.

Any suggestions how can I do this?
Thanks
#812547
Here is trigger code to copy a file from the subprocess case to the parent case:
Code: Select all
//set to the ID of the Input Document in the parent process:
$parentInpDocId = '5900867485a320fcbd9cef5036298389'; 

//find parent case ID:
$caseId = @@APPLICATION;
$sql = "SELECT APP_PARENT FROM SUB_APPLICATION WHERE APP_UID='$caseId'";
$aResult = executeQuery($sql);
if (!is_array($aResult) or count($aResult) == 0) {
    throw new Exception("Parent case for subcase $caseId is not in SUB_APPLICATION table.");
}
$parentCaseId = $aResult[1]['APP_PARENT']; 

//find if any files for this subproces case and send them to the parent case:
$sql = "SELECT * FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND APP_DOC_STATUS='ACTIVE'";
$aFiles = executeQuery($sql);

foreach ($aFiles as $aFile) {
   @@res = PMFCopyDocumentCase($aFile['APP_DOC_UID'], $aFile['DOC_VERSION'], 
        $parentCaseId, $parentInpDocId);    
}
 
Set this code to fire in the subprocess. If you want to display the file in a File or Multiple File control in a Dynaform in the parent case, then you also need to write the variable name of the File field in the APP_DOCUMENT.APP_DOC_FIELDNAME field. See: viewtopic.php?f=44&t=730024#p812490

If you want to send a file from the parent case to the subprocess case, then you can use this trigger code:
Code: Select all
//set to the ID of the Input Document in the subprocess:
$subInpDocId = '6415952415a31f302a413b9055751015'; 

//find subprocess case ID:
$caseId = @@APPLICATION;
$sql = "SELECT APP_UID FROM SUB_APPLICATION WHERE APP_PARENT='$caseId'";
$aResult = executeQuery($sql);
if (!is_array($aResult) or count($aResult) == 0) {
    throw new Exception("Subprocess case for parent case $caseId is not in SUB_APPLICATION table");
}
$subCaseId = $aResult[1]['APP_UID']; 

//find if any files for this case and send them to the subprocess case:
$sql = "SELECT * FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND APP_DOC_STATUS='ACTIVE'";
$aFiles = executeQuery($sql);

foreach ($aFiles as $aFile) {
   @@res = PMFCopyDocumentCase($aFile['APP_DOC_UID'], $aFile['DOC_VERSION'], 
        $subCaseId, $subInpDocId);    
} 
If the subprocess is synchronous, then this trigger needs to be fired after routing in the task before the the suprocess in the parent process.

Here are sample parent process and subprocess which shows how to use both triggers:
Parent process:
(45.99 KiB) Downloaded 88 times
Subprocess:
(28.79 KiB) Downloaded 93 times
Task doesnt have any users.

I have created a small process. Users are assigned[…]

NEW MOBILE APP ISSUE

Just trying to setup to use the mobile App with my[…]

It's really a great idea. I have followed the seco[…]

yes i use php thanks for the information