How to include most recent comments in the grid


Instructions

  1. Select Module in the top left banner then select the appropriate module name link.
  2. Select the appropriate module for which the comments in the grid are required.
  3. Scroll down in the Module Properties enabling the [Show Rolledup Comments in the grid], then select Save.
  4. Select the Forms tab, followed by the Field List button "Create/Update Fields".
  5. Search for "RolledupComments" in the field search above the field listing, select the field for editing.
  6. Enable [Show in grid] and [Hide in form].
  7. In the Column Header property type "Most Recent Comment".
  8. Select the Grid tab, pasting the formatting below into the Column Template section.

    <div class="ui-grid-cell-contents">

        {{grid.appScope.executeCustomJs(grid, row, col);}}

    </div>

  9. In the Custom JavaScript section paste the code below.

    var cellValue = grid.getCellValue(row, col);

    if (cellValue) {
        var retValue = '';
        var myToDRegEx = /([0-9]+:[0-9]+:[0-9]+ [A|P]M)(.*)/gm;
        var timeOfDay = myToDRegEx.exec(cellValue);
        var commentRegEx = /<\/span><br\/>(?!<span>)(?:.)*?<br\/>/m;
        var commentStr = commentRegEx.exec(cellValue);


        if (commentStr && commentStr.length > 0) {
            // remove up to the first close span
            var trimmedFirstSpan = commentStr[0].substring(12);
            var comment = "";

           // find first open span
           var afterSpan = trimmedFirstSpan.indexOf("<br/>");

            if (afterSpan >= 0) {
               comment = trimmedFirstSpan.substring(0, afterSpan);
               comment = comment.replace(/<(?:.)*?>/gm, '');
           }
            if (timeOfDay && timeOfDay.length > 0 && comment) {
                retValue = timeOfDay[1] + " -- " + comment;
                return retValue;
            }
        }
    }
    return undefined;


  10. Save the Field List and return to the form list through the Breadcrumb in the top left or by selecting Module in the top left banner.
  11. Select the Default form, add the RolledupComments field to the form, then Save the Default form.
  12. Return to the main grid view verifying the most recent comment is appearing in the column labeled "Most Recent Comment" in the grid.