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

Moderator: amosbatto

By sowjanya
Dear Team,

I would like to add additional criteria's in the drop down of 'Output documents to generate'. Currently, the drop down has only 3 options 'Both, Doc, PDF', I would like to include 'XML' option in the drop down.

It would be great if you can guide us with the file names in the PM where i can make the necessary changes. We are using the PM v3.0 currently.

Look forward to your response at the earliest as it an urgent requirement we are working on

output documents.png
output documents.png (51.54 KiB) Viewed 1824 times
By andreaadamczyk
Dear sowjanya,

Currently ProcessMaker does not support this option in the Create Output Document interface, but if you want to add that option you could create your own plugin.

Best regards.
User avatar
By amosbatto
To add a new option to the dropdown, edit workflow/engine/xmlform/outputdocs/outputdocs_Properties.xml and change:
Code: Select all
  <OUT_DOC_GENERATE type="dropdown">
    <en><![CDATA[Output Document to Generate]]><option name="BOTH"><![CDATA[BOTH]]></option><option name="DOC"><![CDATA[DOC]]></option><option name="PDF"><![CDATA[PDF]]></option></en>
Code: Select all
  <OUT_DOC_GENERATE type="dropdown">
    <en><![CDATA[Output Document to Generate]]><option name="BOTH"><![CDATA[BOTH]]></option><option name="DOC"><![CDATA[DOC]]></option><option name="PDF"><![CDATA[PDF]]></option><![CDATA[XML]]></option></en>
(If you have added translations to ProcessMaker, make the same change for the other languages as well in the same file.) Delete the ProcessMaker Compiled Cache to see the changes.

Then, you will have to modify the generate() function in workflow/engine/classes/model/OutputDocument.php to detect that the type of Output Document is 'XML' and call your custom function to generate the file.

You can modify the PM source code if you, but I don't recommend it. I would be simpler to create a trigger to generate your XML file from the template file and store it a temporary file on the PM server. Then, use PMFAddInputDocument() to upload the file to the current case and then delete the temporary file. Then, the user can download the file from a File or MultipleFile field in a DynaForm or in an Input Document step.

Here is some example trigger code that will help you:
Code: Select all
//create temporary XML file:
$generatedFilename = 'myfilename.xml'; //set to filename of the generated XML file
$tmpDir = '/tmp';  //set to temporary directory on the PM server;
$xmlFilePath = tempnam( $tmpDir, 'mytemplate_') . '.xml';

//open template file:
$content = file_get_contents(PATH_DATA_MAILTEMPLATES . @@PROCESS . PATH_SEP . 'mytemplate.html');

//insert case variables in the template:
$g = new G();
$oCase = new Cases()
$aCaseInfo = $oCase->LoadCase(@APPLICATION);
$contentInsertedVars = $g->replaceDataGridField($content, $aCaseInfo['APP_DATA']);

//insert content in the temporary XML file:
$result = file_put_contents($xmlFilePath, $contentInsertedVars); 

$inputDocId = '757584323513f501410f3f3061256214'; //set to the ID of the Input Document
$fileId = PMFAddInputDocument($inputDocId, null, 1, 'INPUT', 'generated XML file', 'Add',
   @@APPLICATION, @%INDEX, @@TASK, @@USER_LOGGED, 'file', $xmlFilePath);

//if needing to display the file in a File field or MultipleFile field in a DynaForm
$fileFieldName = 'myXmlFile'; //set to the name of the File field or the ID of the MultipleFile field
$oDoc = new AppDocument();
$aFileInfo = $oDoc->load($fileId);
$aFileInfo['APP_DOC_FIELDNAME'] = $fileFieldname;
//rename from the temporary filename to final filename:
$aFileInfo['APP_DOC_FILENAME'] = $generatedFilename;
//update info about the file in the APP_DOCUMENTS table in the database:  

unlink($xmlFilePath); //delete temporary XML file

//if needing to display the file in a MultipleFile field in a Dynaform, 
//then add variable for the MultipleFile field to the current case:
$aVars = array( 
   $fileFieldName => array(
      'appDocUid' => $fileId, 
      'name' => $generatedFilename,
      'version' => $aFileInfo['DOC_VERSION']
PMFSendVariables(@@APPLICATION, $aVars);
I wrote this code off the top of my head, so it may require some debug, but it gives you an idea how to get started.
By sandyleite
I'm trying to do the same as Sowjanya, but after change the outputdocs_Properties.xml and deleting the compiled cache, nothing happend to the interface, the dropdown list have the same values as before.
Also, after I create the trigger I put it to execute after the dynaform?
I'm using processmaker 3.2.1 installed with bitnami.

Primero, tus comillas estan mal y olvidaste termin[…]

First of all, you are using JavaScript, not Java. […]

Stop submit from javacript

Do it this way: form = $("#637207031573dcea[…]

I can't find the database table where this informa[…]