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);
}
}