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.