PipSqueak wrote:We should be able to have a default template that grabs all variable IDs or labels and its variables and display it into 2 columns. Furthermore, with the control ID e.g. grid, radio, etc we should be able to CSS it for the output document so that everything appears nice and clean on the output document. Sort of like a “for each...then..” variable
CSS doesn't work in Output Documents due to the nature of the TCPDF library.
To output all the variables in a case, you can use this trigger code like this:
Code: Select all//add the variables to exclude from output table:
$aVarsToExclude = array("APPLICATION", "INDEX", "APP_NUMBER", "PROCESS",
"TASK", "PIN", "USER_LOGGED", "USR_USERNAME", "SYS_SYS", "SYS_LANG",
"SYS_SKIN", "__ERROR__", "__VAR_CHANGED__"
"reviewDate", "reviewDate_label");
//add the variables that should be shown even if blank:
$aVarsToShowIfBlank = array('reviewer', 'firstUserId');
$c = new Cases();
$aCase = $c->LoadCase(@@APPLICATION);
@=varList = array();
$counter = 1;
foreach ($aCase['APP_DATA'] as $varName => $varValue) {
if (!in_array($varName, $aVarsToExclude) and
(!empty($varValue) or in_array($varName, $aVarsToShowIfBlank)))
{
@=varList[$counter++] = array(
"variable" => $varName,
"value" => $varValue
);
}
}
You can add the names of your variables to exclude and the variables which should always be printed.
Then, you can use this HTML code in your Output Document template:
Code: Select all<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
</head>
<body>
<p></p>
<center><b>Case Variables</b></center>
<p></p>
<table style="border-collapse: collapse;" cellspacing="0" cellpadding="3" bordercolor="blue" border="1">
<tbody>
<tr><th><b>Variable</b></th><th><b>Value</b></th></tr>
<!-- @>varList -->
<tr>
<td>@#variable</td>
<td>@#value</td>
</tr>
<!-- @<varList --></tbody>
</table>
</body>
</html>
PipSqueak wrote:Is there a custom script or trigger that makes it easy for users to generate output document with a default template. For instance, each dynaform control already has an ID on it e.g. grid, text, radio, etc...
This trigger code used to work, but I just discovered that PMFDynaformFields() in not working in PM 3.2.1. I'm not sure in what version of PM it stopped working. You can try this if you have an older version of PM.
Trigger code:
Code: Select all//Example outputting the variables in a DynaForm:
//set to the ID of the Dynaform:
$dynaformUID = '5568431605a99e771c4e9c4068144585';
//field types to print values:
$aPrintTypes = array('text', 'textarea', 'dropdown', 'suggest', 'checkbox', 'radio');
$aFields = PMFDynaFormFields($dynaformUID, @@APPLICATION, @%INDEX);
@@formVarsTable = '<table style="border-collapse: collapse;" '.
'cellspacing="0" cellpadding="3" bordercolor="blue" border="1">'.
"\n<tr><th>Field</th><th>Value</th></tr>\n";
foreach ($aFields as $aField) {
if (in_array($aField->type, $aPrintTypes)) {
@@formVarsTable .= "<tr><td>". $aField->label ."</td>".
"<td>". $aField->value_label ."</td></tr>\n";
}
}
@@formVarsTable .= "</table>";
Then, the Output Document contains: