From pmusers
Revision as of 21:31, 26 November 2018 by Amosbatto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

Plugin: CustomFunctions-1.tar (right click and select Save Link As)

The attached plugin contains just one custom function. The customFunctions_getAllCaseDocuments() function queries the APP_DOCUMENT table based on filters entered as parameters to the function and returns a grid-like array with information about the documents.

array customFunctions_getAllCaseDocuments($caseId, $filterByDocId, $filterByDocType, $filterByUser, $filterByTags, $filterRecentOnly)


  • $caseId: The ID of the case. If not set, the current case ID will be used. If set to "ALL", results are not filtered. If a specific case ID is given, the ID is used in a query.
  • $filterByDocId: Filters results by document Id
  • $filterByDocType: Filters Input Documents if "INPUT" is given. If "OUTPUT" is given, it filters output documents. If not set, results are not filtered.
  • $filterByUser: Filters documents by user if UID is given. If not set, results are not filtered.
  • $filterByTags: filters documents by tags using strpos. If not set, results are not filtered.
  • $filterRecentOnly: shows only the most recent version of the document if the parameter is set. If not set, results are not filtered

NOTE: Even though the function allows to query documents for ALL cases, this may take very long based on the number of documents in the APP_DOCUMENT table. Therefore, make sure you use other parametres (e.g. tags) in the function to filter the table.


Returns a grid-like array with the following keys:

  • filename: Name of the file with extension. In case of OUTPUT documents, it always returns PDF.
  • category: The document tags. In case tags are used in the filter, it will return only the relevant tag.
  • uploadDate: Datetime when the document was uploaded in "YYYY-MM-DD HH:MM:SS" format.
  • version: Version number of the document, which starts counting from 1.
  • filePath: Full path to the file on the ProcessMaker server.
  • url: URL to access the file.
  • status: Status of the document, which can be "ACTIVE" or "DELETED".


If you want to send e-mail with an attachment, you may use this function in a trigger like this:

//this will return the latest version of all input and output documents for the current case)
$documentsArray = customFunctions_getAllCaseDocuments($caseId,NULL,NULL,NULL,NULL,NULL,1); 

foreach(documentsArray as $row=>$column){
   $annexes[$column['filename']] = $column['filePath'];
PMFSendMessage(@@APPLICATION, $from,$to,'','','Test annexes','testTemplate.html',array(),$annexes);