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

Moderator: amosbatto

By sowjanya
#793960
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

Regards,
Sowjanya
Attachments
output documents.png
output documents.png (51.54 KiB) Viewed 1134 times
By andreaadamczyk
#814747
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.
By amosbatto
#814748
Sowjanya,
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>
To:
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:  
$oDoc->update($aFileInfo);   

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.

Thanks Amos, it kinda of worked. But the API respo[…]

Data table in the panel

Create a hidden field associated with the variab[…]

Timo, that code has been moved to: workflow/engine[…]

routeCase SOAP API error

There is no web service function to get all the va[…]