truncating case description in case assignment email

sure its 2022 and we have force lightning powers that emperor palpatine himself could only dream of, but if you want a good case assignment email, you need visualforce.

i rolled up a nice visualforce email template years ago that includes the case commments - sorted by date!

but the template includes case description, and sometimes people initiate a case via a gigantic email, and all of that email thread would come through on the visualforce assignment email

so i just need to truncate the length of the description.

the original
<apex:outputField value="{!relatedTo.Description}"></apex:outputField>

tried inserting a left in there, could not get anything to save

apex:outputText would lose the formatting, regardless of how I tried to work with it, like


I even tried abbreviating the string in a vf component, but outputText would lose the formatting

But to work with apex:outputField you need a sObject.

So in my custom component, instead of returning a string, I return a case sObject, with a truncated description field, and used apex:outputField

public with sharing class SortedCaseCommentsController {

  public Id     AttributeCaseId    {get; set;}

  public List<CaseComment> getCaseComments() {
    return [
      SELECT CommentBody, CreatedById, CreatedBy.Name, CreatedDate
      FROM CaseComment
      WHERE ParentId =: this.AttributeCaseId
      ORDER BY CreatedDate DESC LIMIT 3

  public case getCaseDescription(){
      IF(this.AttributeCaseId != NULL){
      list<Case> caseList = new list<Case> ([select description from Case where Id =: this.AttributeCaseId ]);
      caseList[0].description = caseList[0].description.abbreviate(1500);
      return caseList[0];
      ELSE{return null;}


Now read this

Flow to check and redirect to create / edit if…

Scenario: Check if record (meeting certain criteria) already exists, if not redirect to standard create new page, else redirect to view record Example: client services - wants all records for a client from a single day under a single... Continue →