Page 1 of 1

Generate output document from Grid

Posted: Thu Nov 09, 2017 5:01 am
by ahmadkastero
Dears, Good day.
I'm New in ProceessMaker and i build a new process and a part of that process there is a grid and i need to generate the values from that grid.
the grid contain drop down list and date and text.

how can i post values in output document regardless on how many records i have ;to be "Dynamic "/.

please help me on this.

Re: Generate output document from Grid

Posted: Fri Nov 10, 2017 12:58 am
by amosbatto
See: http://wiki.processmaker.com/3.0/Output ... _documents

In the grid field that contains a dropdown, if the field has an ID of "Product", then you should use @#Product_label instead of @#Product to get the displayed label.

Re: Generate output document from Grid

Posted: Sat Nov 11, 2017 1:23 pm
by ahmadkastero
Thank you very much but i try and doesn't work it works with drop down list the normal one not that inside grid.
i attached one sample for what i'm working on if you can help please.

Re: Generate output document from Grid

Posted: Tue Nov 14, 2017 12:17 am
by amosbatto
In your HTML code for your grid in the Output Document, change this code from:
Code: Select all
<table cellspacing="0" border="1">
<tbody>
<tr><th>Product</th><th>First Expiry Date</th><th>Comments</th></tr>
<[email protected]>ProductCheck_Grid-->
<tr>
<td>@@dropdown0000000001</td>
<td>@#DropProduct</td>
<td>@%text0000000002</td>
</tr>
<[email protected]<ProductCheck_Grid--></tbody>
</table>
To:
Code: Select all
<table cellspacing="0" border="1">
<tbody>
<tr><th>Product</th><th>First Expiry Date</th><th>Comments</th></tr>
<[email protected]>ProductExpiryCheck_Grid-->
<tr>
<td>@#DropProduct_label</td>
<td>@#datetime0000000001_label</td>
<td>@#text0000000002</td>
</tr>
<[email protected]<ProductExpiryCheck_Grid--></tbody>
</table>
Your problems:
1. You were using the wrong grid variable.
2. You should use @#variable, not @%variable.
3. For dropdowns and datetimes you should use @#variable_label
4. You misspelled some of the IDs of the fields in the grid.

Re: Generate output document from Grid

Posted: Thu Nov 16, 2017 3:17 am
by ahmadkastero
amosbatto wrote:In your HTML code for your grid in the Output Document, change this code from:
Code: Select all
<table cellspacing="0" border="1">
<tbody>
<tr><th>Product</th><th>First Expiry Date</th><th>Comments</th></tr>
<[email protected]>ProductCheck_Grid-->
<tr>
<td>@@dropdown0000000001</td>
<td>@#DropProduct</td>
<td>@%text0000000002</td>
</tr>
<[email protected]<ProductCheck_Grid--></tbody>
</table>
To:
Code: Select all
<table cellspacing="0" border="1">
<tbody>
<tr><th>Product</th><th>First Expiry Date</th><th>Comments</th></tr>
<[email protected]>ProductExpiryCheck_Grid-->
<tr>
<td>@#DropProduct_label</td>
<td>@#datetime0000000001_label</td>
<td>@#text0000000002</td>
</tr>
<[email protected]<ProductExpiryCheck_Grid--></tbody>
</table>
Your problems:
1. You were using the wrong grid variable.
2. You should use @#variable, not @%variable.
3. For dropdowns and datetimes you should use @#variable_label
4. You misspelled some of the IDs of the fields in the grid.


Thank you very much it works, may i ask one more thing!
How can i get the check box value in out put document if it checked to appear'Yes' if not 'No'.!

Re: Generate output document from Grid

Posted: Thu Nov 16, 2017 6:44 pm
by amosbatto
ahmadkastero wrote:
amosbatto wrote:Thank you very much it works, may i ask one more thing!
How can i get the check box value in out put document if it checked to appear'Yes' if not 'No'.!
In the properties of the checkbox in Dynaform Editor, you need to set the list of "options" to have labels of "Yes" and "No":
CheckBoxOptionsList.png
CheckBoxOptionsList.png (38.9 KiB) Viewed 5613 times
Then use @#variable_label in your Output Document.

Re: Generate output document from Grid

Posted: Sun Nov 19, 2017 2:49 am
by ahmadkastero
Thank you very much but this is if it was normal check box i can define the values but in a Grid there is no value i can define it! in this case how can i apply that?

Re: Generate output document from Grid

Posted: Mon Nov 20, 2017 8:36 pm
by amosbatto
ahmadkastero wrote:Thank you very much but this is if it was normal check box i can define the values but in a Grid there is no value i can define it! in this case how can i apply that?
Create a trigger like this in your process:
Code: Select all
if (isset(@=myGrid) and is_array(@=myGrid)) {
   $len = count(@=myGrid);
   for ($i = 1; $i <= $len; $i++) {
      if (@=myGrid[$i]['myCheckbox'] == '1') {
         @=myGrid[$i]['myCheckbox_label'] = 'Yes';
      }
      else {
         @=myGrid[$i]['myCheckbox_label'] = 'No';
      }
   }
} 
Where the grid variable is "myGrid" and the ID of the checkbox field in the grid is "myCheckbox". Set this trigger to fire after the DynaForm containing the grid.

Then, you can use @>myGrid @#myCheckbox_label @<myGrid in your Output Document.

Re: Generate output document from Grid

Posted: Tue Feb 20, 2018 12:31 pm
by mjeanbaptiste
Hi amos i'm working on something similar.
Using that trigger can i tell it not to show the whole row of the grid in the ouput document if it is "NO"? If yes can you please tell me what code to use? Thank you in advance.

Re: Generate output document from Grid

Posted: Tue Feb 20, 2018 9:47 pm
by amosbatto
mjeanbaptiste wrote:Hi amos i'm working on something similar.
Using that trigger can i tell it not to show the whole row of the grid in the ouput document if it is "NO"? If yes can you please tell me what code to use? Thank you in advance.
You should create a copy of the grid variable which doesn't include the rows which have the checkbox set to "NO".

Create the following trigger and set it to execute after the Dynaform containing the grid:
Code: Select all
if (isset(@=myGrid) and is_array(@=myGrid)) {
   @=myGridCopy = array();
   $len = count(@=myGrid);
   $i = 1; //counter in original grid
   $iCopy = 1; //counter in filtered grid copy
   for (; $i <= $len; $i++) {
      if (@=myGrid[$i]['myCheckbox'] == '1') {
         @=myGrid[$i]['myCheckbox_label'] = 'Yes';
         @=myGridCopy[$iCopy] = @=myGrid[$i];
         $iCopy++;
      }
   }
}

where "myGrid" is the variable associated with the grid and the checkbox inside the grid has the ID "myCheckbox".

Then you can use this HTML code your Output Document template:
Code: Select all
<table cellspacing="0" border="1">
<tbody>
<tr><th>Field 1</th><th>My Checkbox</th></tr>
<[email protected]>myGridCopy-->
<tr>
<td>@#myField1_label</td>
<td>@#myCheckbox_label</td>
</tr>
<[email protected]<myGridCopy-->
</tbody>
</table>

Re: Generate output document from Grid

Posted: Fri Feb 23, 2018 3:51 pm
by mjeanbaptiste
amos I Have been going at this and my ouput comes out blank here is my trigger
Code: Select all
if (isset(@=listesite) and is_array(@=listesite)) {
   @=listesiteCopy = array();
   $len = count(@=listesite);
   $i = 1; 
   $iCopy = 1; 
   for (; $i <= $len; $i++) {
      if (@=listesite[$i][valid] == 1) {
         @=listesite[$i][valid_label] = Oui;
         @=listesiteCopy[$iCopy] = @=listesite[$i];
         $iCopy++;
      }
   }
} 

Re: Generate output document from Grid

Posted: Fri Feb 23, 2018 3:52 pm
by mjeanbaptiste
Here's my output

<!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 align="center"><font size="4"><b>Liste des sites valid&eacute;s @#datedemande<br /></b></font></p>
<hr />
<p align="center"></p>
<table cellspacing="0" border="1">
<tbody>
<tr><th align="center">Contact</th><th align="center">T&eacute;l&eacute;phone</th><th align="center">Nom du&nbsp; Site</th><th align="center">GPS</th><th align="center">Profondeur</th><th align="center">Valid&eacute;?</th><th align="center">Commentaires</th></tr>
<[email protected]>listesiteCopy-->
<tr>
<td>@#contact_label</td>
<td align="center">@#tel_label</td>
<td align="center">@#nomsite_label</td>
<td align="center">@#gps_label</td>
<td align="center">@#profondeur_label</td>
<td align="center">@#valid_label</td>
<td align="center">@#commentaire_label</td>
</tr>
<[email protected]<listesiteCopy--></tbody>
</table>
<p></p>
<p></p>
<p><font size="4"><b>Commentaires:</b></font></p>
<p>@#comments</p>
<p></p>
<p></p>
<p></p>
<p></p>
</body>
</html>