Questions and discussion about developing processes and programming in PHP, JavaScript, web services & REST API.
Forum rules: Please search to see if a question has already asked before creating a new topic. Please don't post the same question in multiple forums.
By andreaadamczyk
#817502
Hello,

You can create an array type variable, and in a trigger before the output document, set the value of that variable with the array.

Then, in the HTML editor of the output document you can use this code to create the document:
Code: Select all
<table width="100%" border="1">
<!--@>GRID-VARIABLE-NAME-->
<tr>
<td width="25%">@#Field1</td>
<td width="25%">@#Field2</td>
<td width="25%">@#Field3</td>
<td width="25%">@#Field4</td>
</tr>
<!--@<GRID-VARIABLE-NAME-->
</table>
Where the "GRID-VARIABLE-NAME" is the name of the array variable you created before, and the "Field-X" are the fields of the array.

I hope this information would help you.

Please, let me know how it goes.

Regards.
By fibo2358
#817514
Hello ,

Thank you very much, that worked fine.
I guess that the documentation should be updated, it is not obvious that the solution used in grids may be applied to the arrays.
I will enter a separate post for this update.

Best Regards,
fibo2358
User avatar
By amosbatto
#824054
HeshanKaru1994 wrote:Can you show a sample code in use with more details as i'm new to processmaker
Where you unable to follow this example?

Are you editing the HTML code in your template? (Look for the "HTML" button in the template editor.)
Are you matching the exact spelling for your Grid variable and the IDs of the fields inside the grid?

If you still can't figure it out, then post your process and indicate which dynaform has the grid and which Output Document should have the inserted grid.
User avatar
By amosbatto
#824071
HeshanKaru1994 wrote: Fri Apr 19, 2019 5:49 am Inside a trigger I am generating array of items(without using grids) and I want that array to be shown inside a html table in a template document
You can use trigger code like this to create an array that looks like a grid to ProcessMaker:
Code: Select all
@=myGrid = array(
  1 => array( 'field1' => 'row1value1', 'field2' => 'row1value2', 'field3' => 'row1value3'),
  2 => array( 'field1' => 'row2value1', 'field2' => 'row2value2', 'field3' => 'row2value3'),
  3 => array( 'field1' => 'row3value1', 'field2' => 'row3value2', 'field3' => 'row3value3')
);

Then use this in the HTML code of your template file:
Code: Select all
<table width="100%" border="1">
<tr><th>My Field 1</th><th>My Field 2</th><th>My Field 3</th></tr>
<!-- @>myGrid -->
<tr>
<td width="32%">@#field1</td>
<td width="32%">@#field2</td>
<td width="32%">@#field3</td>
</tr>
<!-- @<myGrid -->
</table>
By HeshanKaru1994
#824774
Hi my trigger to create array:
Code: Select all
$aKeys = array_keys(@=result);
@=key = array();
for($x=0; $x < $count;$x++){
	@=key[] = $aKeys[$x];	
}
the result of the trigger

Array ( [0] => Array One [1] => Array Two )

How to map this situation to the output table
User avatar
By amosbatto
#824789
If @=result has the structure of a grid variable, then you can include it in the template of your Output Document like a normal grid.

If @=result doesn't have the structure of a normal grid variable, then you will have to create the HTML code for a table and then place that HTML in a case variable which you put in the template of your Output Document.

Can you post the content of your @=result variable? It is hard for me to give you a code example for how to output it as an HTML table without knowing the structure.

For example, if @=result contains:
Code: Select all
[   
    'Expenses' => 2435.48,
    'Revenue' => 5699.50,
    'Income'   => 2300.55
];
Then, you can use the following trigger:
Code: Select all
@@tableContent = "<table>\n";

foreach (@=result as $key => $val) {  
        @@tableContent .= "<tr><td>$key</td><td>$val</td></tr>\n";
}
@@tableContent .= "</table>";

Then, place @#tableContent in your Output Document template.

Experience heightened pleasure with Cenforce 100 M[…]

Get an instant solution to move emails to MBOX for[…]

Most Demanding OST to PST Converter

The most demanding OST to PST Converter is TrijaT[…]

Betvisa clone scripts are pre-built software solut[…]