TrackStudio Enterprise 3.5
Example 2

To collect text from all messages for the current task use the following Task / Custom Field Value script:

String s = "";
for(Iterator it = task.getMessages().iterator(); it.hasNext();) {
    String desc = it.next().getDescription();
    if (desc != null) {
      s += desc + " | ";
    }
}
return s;

Associated custom field properties:

Property 
Value 
Type 
String