How to include most recent comments in the grid
Instructions
- Select Module in the top left banner then select the appropriate module name link.
- Select the appropriate module for which the comments in the grid are required.
- Scroll down in the Module Properties enabling the [Show Rolledup Comments in the grid], then select Save.
- Select the Forms tab, followed by the Field List button "Create/Update Fields".
- Search for "RolledupComments" in the field search above the field listing, select the field for editing.
- Enable [Show in grid] and [Hide in form].
- In the Column Header property type "Most Recent Comment".
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>
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;- 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.
- Select the Default form, add the RolledupComments field to the form, then Save the Default form.
- Return to the main grid view verifying the most recent comment is appearing in the column labeled "Most Recent Comment" in the grid.
Related articles