You are on page 1of 8

Output Documents - ProcessMaker

Page 1 of 8

Output Documents
From ProcessMaker
Output Documents are files generated while running a case, which are meant to be printed out or stored digitally outside ProcessMaker. Output Documents are useful for creating external records of case data, as well as creating formatted output such as bills, receipts, and letters. They are generated from HTML templates containing references to system and case variables, which are auto-inserted when the Output Document is generated as a step when running a case. Output Documents are generated as PDF (Portable Document Format) and/or DOC (Word document) files, so they can be easily opened and printed using Adobe Acrobat and Microsoft Office (or alternatives such as Foxit Reader, Evince, Okular, WordPerfect, AbiWord and OpenOffice).

Contents

1 Creating Output Documents 2 Editing Output Documents 3 Output Document Example 4 Grids in Output documents 5 Output Document Storage 6 Accessing Output Documents through Triggers

Creating Output Documents


To create an Output Document, first open a process. When inside the process map, go to PROCESSES > OUTPUT DOCUMENTS to open a list of Output Documents. Click on New to define a new Output Document:

Define the following fields for the Output Document:

http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes

24-09-2010

Output Documents - ProcessMaker

Page 2 of 8

Title: A label to identify the Output Document. Filename generated: The name of the file to be created when the Output Document is generated while running cases. Description: A description about the Output Document, which should inform the user what is the general content or purpose of the document. Orientation: Select whether the document is in a portrait (vertical) or landscape (horizontal) layout. Output Document to Generate: Select whether the Output Document will be generated in DOC, PDF, or BOTH formats. Enable Versioning: Check this option if needing to keep multiple versions of the Output Document. Versioning is a new option in ProcessMaker 1.2-XXXX and later and is useful if creating the same Output Document at multiple steps during a case. Destination Path: Enter an alternative path to save the Output Documents if not using the default storage path inside ProcessMaker. This is a new option in ProcessMaker 1.2-XXXX and later. Tags: Enter identifying tag word(s) to provide more information about the Output Document. This is a new option in ProcessMaker 1.2-XXXX and later.

After defining the new Output Document, click Save.

Editing Output Documents


To edit an Output Document, click on its Edit link in the Output Documents list. A WYSIWYG HTML editor will open where the content of the Output Document can be easily edited. Enter text and use to toolbar at the top of the editing box to format the document.

Case variables and system variables can be inserted into the Output Document:

@#FIELD-NAME inserts the value of the variable without any changes. @@FIELD-NAME inserts the value of the variable enclosed in "" (double quotation marks).

http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes

24-09-2010

Output Documents - ProcessMaker

Page 3 of 8

Any quotation marks inside the value will be escaped with backslashes, such as "Don\'t say \"hello\"". When done editing, click Save to save the changes to the Output Document. Unfortunately, the WYSIWYG editor allows for only limited formatting, so it is not possible to insert more advanced types of HTML elements such as hyperlinks, images or tables. The HTML code must be directly edited to insert these sorts of elements. In order to edit the HTML code, open the MySQL database with phpMyAdmin. Go to the CONTENT table in the wf_<WORKSPACE> database (which is probably the default workspace wf_workflow). Find all the templates for Output Documents by clicking on the SQL tab in phpMyAdmin and entering the following query:
SELECT * FROM CONTENT WHERE CON_CATEGORY='OUT_DOC_TEMPLATE'

To find a specific Output Document, specify its unique ID in the query:


SELECT * FROM CONTENT WHERE CON_CATEGORY='OUT_DOC_TEMPLATE' AND CON_ID='XXXXXXXXXXXXXXXXXXXXXXXXXX';

The HTML code for the Output Document template is located in the CON_VALUE field. Although the HTML code can be edited directly inside phpMyAdmin, it is easier to copy the code and paste it an HTML editor (such as DreamWeaver, FrontPage or KompoZer) where it can easily be altered. When finished editing the code, paste it back into the CON_VALUE field in phpMyAdmin.

Output Document Example


Here is a sample Output Document template for an Approval Letter which is used in the Credit Card Application process (which is available for download from the ProcessMaker Library). In this example, the several case variables are inserted into the form letter which is sent to applicants who have been approved to receive a credit card:
@#TASK_DATE Mr./Ms. @#APPLICANT_NAME @#APPLICANT_LAST @#APPLICANT_EMAIL Dear Mr./Ms. @#APPLICANT_LAST After reviewing your application for a @#CARD_TYPE card, I inform you that your application was approved for a credit limit of @#CREDIT_LIMIT Dollars. In the next few days you will receive an agreement. You should sign it and return us. Then you will receive your new credit card. If you need further information do not hesitate in contacting our credit card center at 1-800-567-2333. Thank you for trusting our organization. Best Regards @#CREDIT_OFFICER Credit Card Center Supervisor

Grids in Output documents


Fields from grids can also be inserted into Output Documents, but they need to be enclosed inside open and closing tags for the grid. Use the tag @>GRID-NAME to open the grid and @<GRID-NAME to

http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes

24-09-2010

Output Documents - ProcessMaker

Page 4 of 8

close the grid, where GRID-NAME is the name of a grid object in a master DynaForm or an array of associative arrays. This array can be a case variable manually defined in a trigger or returned by querying a database with executeQuery(). Between these tags, include the variables for the fields in that grid:
@>GRID-NAME @#FIELD-1 @#FIELD-2 @#FIELD-3 @<GRID-NAME

The fields enclosed in the opening and closing grid tags will be repeated as many times as there are rows in the grid. For example, if designing a travel expenses report, the following Output Document would list each of the expenses in a grid named "EXPENSE_GRID":
Travel Expense Report @#FIRST_NAME @#LAST_NAME @#REPORT_MONTH Date Type of Expense @>EXPENSE_GRID @#DATE @#TYPE @<EXPENSE_GRID Description @#DESCRIPTION Amount @#AMOUNT

The default font for Output Documents is Arial, which is a variable-width font. It is hard to create neat columns of data with a variable-width font, so it may be useful to either add HTML formatting to use a fixed-width font or to place the grid fields inside an HTML table. In order to directly edit the HTML code, the template will have to be edited inside the MySQL database. Here is an example of the same grid fields inside an HTML table:
<CENTER> Travel Expense Report <BR> @#FIRST_NAME @#LAST_NAME <BR> @#REPORT_MONTH <BR> <BR> <TABLE> <TR> <TH> Date </TH> <TH> Type Of expense </TH> <TH> Description </TH> <TH> Amount </TH> </TR> @>EXPENSE_GRID <TR> <TD> @#DATE </TD> <TD> @#TYPE </TD> <TD> @#DESCRIPTION </TD> <TD> @#AMOUNT </TD> </TR> @<EXPENSE_GRID </TABLE> </CENTER>

Although the EXPENSE_GRID could come from a grid DynaForm, it could also be generated by using executeQuery() to query a PM Table or an external database. If the database has different field names than those in the Output Document, use "AS" to rename the fields. For example, a trigger containing the following code could be fired before the above Output Document is generated:

http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes

24-09-2010

Output Documents - ProcessMaker

Page 5 of 8

$db = 'XXXXXXXXXXXXXXXXXXXXXXXXXXX'; //Unique ID for an external database $query = 'SELECT EXP_DATE AS DATE, EXP_TYPE AS TYPE, EXP_DESC AS DESCRIPTION, EXP_AMT AS AMOUNT FROM EXPENSES"; @@EXPENSE_GRID = executeQuery($query, $db);

Likewise, the trigger could manually create @@EXPENSE_GRID as an array of associative arrays:
@@EXPENSE_GRID = array( array('DATE'=>'2010-04-25', 'TYPE'=>'Airfare', 'DESCRIPTION'=>'Flight to Paris', 'AMOUNT'=>1295.35), array('DATE'=>'2010-04-26', 'TYPE'=>'Lodging', 'DESCRIPTION'=>'Sheraton Hotel', 'AMOUNT'=>300.00 ), array('DATE'=>'2010-04-27', 'TYPE'=>'Meals', 'DESCRIPTION'=>'Lunch w/ client', 'AMOUNT'=>104.95 ) );

Output Document Storage


The definitions of Output Documents are stored in the wf_<WORKSPACE>.OUTPUT_DOCUMENT table in the MySQL database. This table, however, doesn't contain the title, description, template and filename for Output Documents, because this information can be multilingual with a different version for each language. Instead, this information is stored in the wf_<WORKSPACE>.CONTENT table under different ISO 639-1 language codes, such as "en" for English or "es" for Spanish. To find the title, description, template and filename for Output Documents, enter MySQL (either from the command line or with graphical program such as phpMyAdmin) or access it through a function such as executeQuery() in a trigger. Search for a value of 'OUT_DOC_TITLE', 'OUT_DOC_DESCRIPTION', 'OUT_DOC_TEMPLATE', and 'OUT_DOC_FILENAME' in the wf_<WORKSPACE>.OUTPUT_DOCUMENT.CON_CATEGORY field. Use the following SQL query to see all the entries related to Output Documents:
select CON_CATEGORY, CON_ID, CON_LANG from CONTENT where CON_CATEGORY like 'OUT_DOC_%'

To see the information about a particular Output Document, search for its unique ID, which can either be found in the field wf_<WORKSPACE>.OUTPUT_DOCUMENT.OUT_DOC_UID or by opening the list of Output Documents inside ProcessMaker 1.2-2838 or later and clicking the UID link for an Output Document. Once the unique ID is known, it can be used in a SQL query:
select * from CONTENT where CON_ID = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'

For example, here is an Output Document defined in both English and Spanish:

mysql> select * from CONTENT where CON_ID = '2136030664a9bfeb8a775d7029704021'; +---------------------+----------------------------------+----------+-------------------------------------------| CON_CATEGORY | CON_ID | CON_LANG | CON_VALUE +---------------------+----------------------------------+----------+-------------------------------------------| OUT_DOC_TEMPLATE | 2136030664a9bfeb8a775d7029704021 | en | Dear @#ClientName,<br>Please open case @#Ca | OUT_DOC_TITLE | 2136030664a9bfeb8a775d7029704021 | en | Open Case Letter | OUT_DOC_DESCRIPTION | 2136030664a9bfeb8a775d7029704021 | en | Letter asking client to open the case | OUT_DOC_FILENAME | 2136030664a9bfeb8a775d7029704021 | en | OpenCaseLetter | OUT_DOC_TEMPLATE | 2136030664a9bfeb8a775d7029704021 | es | Estimado @#ClientName,<br>Por favor abra ca | OUT_DOC_TITLE | 2136030664a9bfeb8a775d7029704021 | es | Carta - Abrir Caso | OUT_DOC_DESCRIPTION | 2136030664a9bfeb8a775d7029704021 | es | Carta pidiendo que el cliente abra el caso | OUT_DOC_FILENAME | 2136030664a9bfeb8a775d7029704021 | es | CartaAbrirCaso +---------------------+----------------------------------+----------+--------------------------------------------

http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes

24-09-2010

Output Documents - ProcessMaker

Page 6 of 8

Note that a multilingual Output Document like this can be created by first logging into ProcessMaker in English and creating the Output Document, then logging into ProcessMaker in Spanish and editing the same output document in Spanish. When Output Documents are generated while running a case, an HTML file is created based upon the Output Document's template. From that HTML file, a PDF and/or DOC file are created. (Actually the DOC file is really just HTML code inside a DOC container.) In GNU/Linux or UNIX, Output Document files are saved at:
<INSTALL-DIRECTORY>/shared/sites/<WORKSPACE>/files/<CASE-UID>/outdocs/<OUT_DOC_FILENAME>.html /<OUT_DOC_FILENAME>.pdf /<OUT_DOC_FILENAME>.doc

For example:
/opt/processmaker/shared/sites/workflow/files/a03459e1cb9824dac456780eca7b5cf6/outdocs/OpenCaseLetter.html

In Windows, Output Document files are saved at:


<INSTALL-DIRECTORY>\apps\processmaker\shared\<WORKSPACE>_data\files\<CASE-UID>\outdocs\<OUT_DOC_FILENAME>.html \<OUT_DOC_FILENAME>.pdf \<OUT_DOC_FILENAME>.doc

For example:

c:\Program Files\ProcessMaker\apps\processmaker\shared\workflow_data\files\a03459e1cb9824dac456780eca7b5cf6\outdo

Accessing Output Documents through Triggers


In order to access an Output Document in a trigger, the Unique ID (UID) for the Output Document definition needs to be looked up. In older versions of ProcessMaker, the UID can be found by using executeQuery() to look it up in the field wf_<WORKSPACE>.OUTPUT_DOCUMENT.OUT_DOC_UID , or by going to PROCESSES > INPUT DOCUMENTS and clicking on the UID link next to the output document in recent versions of ProcessMaker.

http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes

24-09-2010

Output Documents - ProcessMaker

Page 7 of 8

Example 1: Get the UID for a specific output document for a case:
$docId='XXXXXXXXXXXXXXXXXXXXX'; $caseId = @@APPLICATION; $result = executeTrigger("SELECT * FROM APP_DOCUMENT WHERE APP_UID='$caseId' AND DOC_UID='$docId'"); if (is_array($result) and count($result) > 0) { @@appDocUid = $result['APP_DOC_UID']; }

If the process is going to be exported and imported into another ProcessMaker server, then an new UID will be assigned to the Output Document when it is imported. Therefore, the code can be made more portable by looking up the UID of the Output Document definition in the MySQL database. For instance if the title of the Output Document is "Invoice", then look up that title in the wf_<WORKSPACE>.CONTENT table. Replace the line:
$docId='XXXXXXXXXXXXXXXXXXXXX';

With the code:


$process = @@PROCESS; $outDocTitle = "Invoice"; $query = "select OD.OUT_DOC_UID from OUTPUT_DOCUMENT as OD, CONTENT as C where " . "OD.OUT_DOC_UID=C.CON_ID and C.CON_CATEGORY='OUT_DOC_TITLE' and CON_VALUE='$outDocTitle'"; $result = $executeQuery($query); if (!is_array($result) or count($result) < 1) die("Error: Unable to find output document '$outDocTitle' in database!"); else $docId = $result[1]['OD.OUT_DOC_UID'];

Example 2: This example sends the contents of an output document in an email. Output Documents which are generated in DOC format are basically just HTML code inside of a file with a ".doc" extension, so the HTML code can easily be extracted from the file and inserted into an email (as long as the recipient's email client supports HTML). First, open the process and right click on the process map and select the option Process File Manager from the dropdown menu. Go to the mailTemplates directory and create an email template with an inserted variable named @#Contents which will hold the contents of Output Document:
Dear Supervisor, Here is the output document for the case: @#Contents

Then, create a trigger to extract the contents the output document and pass them to the email so they can be inserted in the @#Contents variable in the email template. The 'Contents' variable can be passed as a key-value pair in an associative array, which is the last parameter for the PMFSendMessage() function.

http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes

24-09-2010

Output Documents - ProcessMaker

Page 8 of 8

$filename = 'FILENAME.doc'; //The FILENAME is set when defining the output document $case = @@APPLICATION; $contents = file_get_contents("INSTALL-DIRECTORY/shared/sites/workflow/files/$case/outdocs/$filename"); $PMFSendMessage(@@APPLICATION, 'from@example.com', 'to@example.com', , , 'Output Document for case', 'MyOutputDocument.html', array('Contents'=>$contents));

Replace FILENAME and INSTALL-DIRECTORY with the appropriate values and set this trigger to fire after the output document is generated. Retrieved from "http://wiki.processmaker.com/index.php/Output_Documents"

This page was last modified on 13 August 2010, at 19:33. Content is available under Sourceforge Logo.

http://wiki.processmaker.com/index.php?title=Output_Documents&printable=yes

24-09-2010

You might also like