Since templates are based on HTML you can use HTML coding to form the template as you want. Below you may find more information about tables and lists in HTML:
We can recommend you to setup a printable with the data from a detail and then send it with the help of a business process. The example of the implementation is described below:
You can implement you business task by the means of business process. The idea is to add read data elements, which would retrieve needed data from particular records. Afterwards, use “send email” business element to combine data into email and send it. You can add a button on the section, or action to trigger the process.
Please see the following article. You can use this example to select needed records and pass this info to business process to send email.
For example, I made this a while back to show a filtered list of products on an order; the HTML is very simple, as it was a demonstration, but that can easily be edited with CSS as necessary. You can see that 'arguments' is passed the record ID if you link the template to a record; the macro is then called by including [#@Invoke.UsrEmailProducts#] in your template.
namespace Terrasoft.Configuration{using System;using Terrasoft;using Terrasoft.Common;using Terrasoft.Core;using Terrasoft.Core.Entities;using Terrasoft.Core.DB;using Newtonsoft.Json;publicclass UsrEmailProducts : IMacrosInvokable
{public UserConnection UserConnection {
get;
set;}public string GetMacrosValue(object arguments){
var sjson = JsonConvert.SerializeObject(arguments);
var templ =new{Key = String.Empty, Value = String.Empty};
var args = JsonConvert.DeserializeAnonymousType(sjson, templ);
var orderId = args.Value;
var esq =new EntitySchemaQuery(UserConnection.EntitySchemaManager, "OrderProduct");
var colCode = esq.AddColumn("Product.Code");
var colDescription = esq.AddColumn("Product.Name");
var colQty = esq.AddColumn("Quantity");
var colSpecs = esq.AddColumn("UsrSpecifications");
var colColour = esq.AddColumn("UsrColour");
var OrderFilter = esq.CreateFilterWithParameters(
FilterComparisonType.Equal, "Order", orderId);
var ModifiedFilter = esq.CreateFilterWithParameters(
FilterComparisonType.Equal, "UsrModified", true);
esq.Filters.LogicalOperation= LogicalOperationStrict.And;
esq.Filters.Add(OrderFilter);
esq.Filters.Add(ModifiedFilter);
EntityCollection entities = esq.GetEntityCollection(UserConnection);
var html ="<table><tr><td>Code</td><td>Description</td><td>Quantity</td><td>Specifications</td><td>Colour</td></tr>";
foreach (Entity entity in entities){
html +="<tr>";
html +="<td>"+ entity.GetColumnValue(colCode.Name).ToString()+"</td>";
html +="<td>"+ entity.GetColumnValue(colDescription.Name).ToString()+"</td>";
html +="<td>"+ entity.GetColumnValue(colQty.Name).ToString()+"</td>";
html +="<td>"+ entity.GetColumnValue(colSpecs.Name).ToString()+"</td>";
html +="<td>"+ entity.GetColumnValue(colColour.Name).ToString()+"</td>";
html +="</tr>";}
html +="</table>";return html;}}}
Edit: All the </> should be proper lt/gt characters, that's just the forum software replacing them.
I'm working together with Luis Gonçalves, and we finally had some time to test your sugestion.
It is actually working perfectly, the table is created in the email in the context of the record ID and there isn't even any need to replace the "</>".
Thank you very much.
I've got one more question for you: this works fine if I start an email from the Case and the ID is passed perfectly.
But if I try to reply to an email that was sent by a costumer and the email is linked with that same Case. Then the conection does not work and the recordID is not retrieved. Any idea how I could make the conection between the macro and the case that is linked with the email that I'm replying to?
I'm afraid that's more of a back-end BPM thing; to the best of my knowledge, the 'arguments' argument ought to hold the current record, but as I'm not a BPM employee, I don't know what the mechanics behind it are. It may be that the 'current record' when you're replying to an email is the Activity object representing the email instead of the Case object, but that's just a guess. I don't know to what extent you're comfortable with the code, but have you tried temporarily returning the contents of the arguments variable (instead of the table) to see what's being passed in?