The comments provided by workflow users are displayed in reverse chronological order in the custom emails in Webtop 5.3 SP 5.
In Webtop 6.5, the comments are not displayed in the reverse chronological order. They were displayed with no particular ordering.
Use Java scriptlets in the custom email templates (JSP) to sort the comments and display, instead of using the and tags.
Two additional custom Java classes are required: Comment.java (POJO) and TimeStampComparator.java.
The Comment.java class will contain the note.writer, note.text and note.creation_date. Each instance of the Comment.java class represents a comment by a workflow user. The TimeStampComparator.java class sorts a list of Comment classes by the note.creation_date attribute, in descending order. The sorting algorithm is determined by using the standard Java libraries, in this case, Collections.sort method.
These two additional classes are packaged into a JAR file and deployed into the JBoss method server on the content server (\Documentum\jboss4.2.0\server\DctmServer_MethodServer\deploy\lib\deploy\lib).
The bpmutil.jar file is required and is also deployed into the JBoss method server (\Documentum\jboss4.2.0\server\DctmServer_MethodServer\deploy\lib\deploy\lib). The ParamResolutionScheme.java class is used in the custom email templates (JSP) for obtaining the note.writer, note.text and note.creation_date.
The approach/logic coded into the JSP email template is as follow:
- For each email rendering, get the total number of comments
- For each comment, get its writer, text and creation_date, and store it to a Comment.java object. Add this object into a list.
- Sort the completed list.
- Iterate through the sorted list, and for each Comment instance in the list, display it out in the HTML and tags. Use the SimpleDateFormat class to format the creation_date according to the required format.
The sample source codes can be found here.