Input collection: myOrders38
OrderID | Item | UnitsOrdered | CostPerUnit |
1001 | Notebook | 25 | 2.5 |
1002 | Crayons | 15 | 8.62 |
1003 | Binders | 10 | 13.34 |
1004 | Pencils | 21 | 1.5 |
1005 | Erasers | 30 | 0.89 |
Output to datasource: mySolution38
<table>
<tr>
<th>OrderID</th>
<th>Item</th>
<th>UnitsOrdered</th>
<th>CostPerUnit</th>
</tr>
<tr>
<td>1001</td>
<td>Notebook</td>
<td>25</td>
<td>2.5</td>
</tr>
<tr>
<td>1002</td>
<td>Crayons</td>
<td>15</td>
<td>8.62</td>
</tr>
<tr>
<td>1003</td>
<td>Binders</td>
<td>10</td>
<td>13.34</td>
</tr>
<tr>
<td>1004</td>
<td>Pencils</td>
<td>21</td>
<td>1.5</td>
</tr>
<tr>
<td>1005</td>
<td>Erasers</td>
<td>30</td>
<td>0.89</td>
</tr>
</table>
Solution code:
//Create a collection
ClearCollect(myOrders38,
{OrderID: 1001, Item: "Notebook", UnitsOrdered: 25, CostPerUnit: 2.5},
{OrderID: 1002, Item: "Crayons", UnitsOrdered: 15, CostPerUnit: 8.62},
{OrderID: 1003, Item: "Binders", UnitsOrdered: 10, CostPerUnit: 13.34},
{OrderID: 1004, Item: "Pencils", UnitsOrdered: 21, CostPerUnit: 1.5},
{OrderID: 1005, Item: "Erasers", UnitsOrdered: 30, CostPerUnit: 0.89}
);
//Collection to HTML Table code
ClearCollect(myHTML,{htmlString:"<table>
<tr>
<th>OrderID</th>
<th>Item</th>
<th>UnitsOrdered</th>
<th>CostPerUnit</th>
</tr>"});
ForAll(
myOrders38,
Patch(
myHTML,
First(myHTML),
{htmlString: First(myHTML).htmlString&"
<tr>
<td>"&OrderID&"</td>
<td>"&Item&"</td>
<td>"&UnitsOrdered&"</td>
<td>"&CostPerUnit&"</td>
</tr>"})
);
Patch(myHTML,First(myHTML),{htmlString: First(myHTML).htmlString&"
</table>"});
Set(mySolution38,First(myHTML).htmlString)