Questions and discussion about using ProcessMaker 2: user interface, running cases and functionality
Forum rules: Please search to see if a question has already been asked before posting. Please don't ask the same question in multiple forums.
By Papine
#781916
Hi!

Please let me know how to attach the case number to the file name. I see the list of number under "APP_NUMBER" on the report table but don't see it on the variable list for Filename generated.

Thanks!
Soojin
User avatar
By amosbatto
#782136
I assume that you want to add the case number to the filename of an input document or an output document file.

For an output document, you need to create a trigger that will be fired before the step which executes the output document. In that trigger use the following code to get the case number:
Code: Select all
$caseId = @@APPLICATION;
$result = executeQuery("SELECT APP_NUMBER FROM APPLICATION WHERE APP_UID='$caseId'");
@@caseNumber = $result[1]['APP_NUMBER']; 
Then in the definition of the Output Documment include the @@caseNumber in the "Filename generated" field. Ex: expenses_@@caseNumber

To include the case number in Input Documents is much harder because you have to fire a trigger after the Input Document step and rename the uploaded file(s). The trigger code would be:
Code: Select all
$caseId = @@APPLICATION;
$result = executeQuery("SELECT APP_NUMBER FROM APPLICATION WHERE APP_UID='$caseId'");
$caseNumber = $result[1]['APP_NUMBER']; 

$inputDocUid = "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"; //place the Input Document's UID here
$query = "SELECT AD.APP_DOC_UID, AD.DOC_VERSION, CON_VALUE AS FILENAME 
    FROM CONTENT C, APP_DOCUMENT AD,   
    WHERE AD.APP_UID='$caseId' AND AD.DOC_UID='$inputDocUid' 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<>'' ";
$docs = executeQuery($query);
 
if (is_array($docs) and count($docs) > 0) {
    foreach($docs as $doc) {
       //take filename and the add case number to the end off it
       $filename = basename($doc['FILENAME']) . '_' . $caseNumber . '.' . pathinfo($doc['FILENAME'], PATHINFO_EXTENSION);
       $fileId = $doc['APP_DOC_UID'];
       $query = "UPDATE CONTENT SET CON_VALUE='$filename' WHERE CON_ID='$fileId' AND CON_CATEGORY='APP_DOC_FILENAME' ";
       executeQuery($query);
    }
}
By dannyng
#786216
Hi Amosbatto,

I know this is a long post but just want to check why I received error that shown in the picture as per attached. I've tried the code given by you and I'm using PM 3.0.18.
Attachments
Capture.PNG
Capture.PNG (53.83 KiB) Viewed 3326 times

A 1xBet clone script is a customizable software so[…]

A Bustabit clone script is a pre-made software sol[…]

Are you looking for ways to pay someone to write m[…]

BC.Game Clone

BC.game clone is a replica of the original BC.game[…]