function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
DRobi83DRobi83 

Richtext Limit Amount of Rows/characters of the field that displays in a Visualforce page

Hello. I am making a 'feed' type visualforce page for my home dashboard, and i am displaying the most recent 5 records. Within those records, there is a richtext type field, which is the "Comment". I am trying to only display the first 5 rows of the field data (not the whole field as the info can get to long and stretch the page). Is there a way to limit the number of rows/characters which display on a richtext field type. I know i can do it on a standard text field, but not a richtext? The field is

 

value="{!t.miiHelpDeskT2__Comment__c}" 

 

Thanks in advance

 

Here is my VF

 

<apex:page standardController="miiHelpDeskT2__Ticket__c" showheader="false" sidebar="false" extensions="TicketCommentFeedList">
<html>
<style type="text/css">
a:link    {
  /* Applies to all unvisited links */
  text-decoration:  none;
  font-weight:      bold;
  color:            blue;
  } 
a:visited {
  /* Applies to all visited links */
  text-decoration:  none;
  font-weight:      bold;
  color:            #f0f;
  } 
a:hover   {
  /* Applies to links under the pointer */
  text-decoration:  underline;
  font-weight:      bold;
  color:            #fff;
  } 
a:active  {
  /* Applies to activated links */
  text-decoration:  underline;
  font-weight:      bold;
  color: white;
  } 
.ticket {font-family:arial,Georgia,Serif; font-size: 12px; font-weight:bold; color:#6699CC}
</style>
  <apex:repeat value="{!TicketCommentFeedList}" var="t" rows="5">
      <table width="100%" border="1" cellpadding="5">
      <tr>
        <td>
        <a href="https://ap1.salesforce.com/{!t.miiHelpDeskT2__Ticket__c}" target="_parent">
        <apex:outputText styleClass="ticket" value="{!t.miiHelpDeskT2__Ticket_Number__c}"/>
        </a>&nbsp;:&nbsp;
        <apex:outputText style="font-size:11px;" value="{!t.miiHelpDeskT2__Subject__c}"/>&nbsp;:&nbsp;
        <apex:outputText style="font-size:11px;" value="{!t.Contact_Who_Made_Comment_Name__c}" escape="false"/>&nbsp;@&nbsp;<apex:outputText style="font-size:11px;" value=" {!t.miiHelpDeskT2__Created_Date_Time__c}"></apex:outputText><br></br><br></br><apex:outputText style="font-size:11px;" value="{!t.miiHelpDeskT2__Comment__c}" escape="false"/>
        
        </td>
      </tr>
      </table> 
  </apex:repeat> 
</html>   
</apex:page>

 

Here is my class

 

public class TicketCommentFeedList {

    private ApexPages.StandardController stdCtrl;
    
    public TicketCommentFeedList(ApexPages.StandardController controller)

    {

        stdCtrl=controller;

    }

    List<miiHelpDeskT2__Ticket_Comment__c> myList;

    Public List<miiHelpDeskT2__Ticket_Comment__c> getTicketCommentFeedList() {

myList = [SELECT Id, Name, miiHelpDeskT2__Ticket__c, miiHelpDeskT2__Active__c, miiHelpDeskT2__Comment__c, miiHelpDeskT2__Contact_Name__c, miiHelpDeskT2__Contact_Who_Made_Comment_Email__c, miiHelpDeskT2__Contact_Who_Made_Comment__c, miiHelpDeskT2__Created_Date_Time__c, miiHelpDeskT2__Is_Member_Comment__c, miiHelpDeskT2__Is_Ticket_Answered__c, miiHelpDeskT2__Public__c, miiHelpDeskT2__Send_Customer_Notification__c, miiHelpDeskT2__Subject__c, miiHelpDeskT2__Ticket_Manager_Email__c, miiHelpDeskT2__Ticket_Manager_Name__c, miiHelpDeskT2__Ticket_Number__c, miiHelpDeskT2__ID_Historic__c, Ticket_Comment_Name_Historic__c, Ticket_Subject__c, Ticket_Description__c, Contact_First_Name__c, Contact_Who_Made_Comment_Name__c FROM miiHelpDeskT2__Ticket_Comment__c WHERE miiHelpDeskT2__Active__c = True ORDER BY miiHelpDeskT2__Created_Date_Time__c DESC ];

    /// ORDER BY CAN BE ASC OR DESC 

    return  myList;

    }

    public static testmethod void Test1()

    {

    Project_Cost__c p=new Project_Cost__c();

    ApexPages.StandardController sc = new ApexPages.standardController(p);

           

    TicketCommentFeedList Tcfl=new TicketCommentFeedList (sc);

    Tcfl.getTicketCommentFeedList();

    }     

}

 

Best Answer chosen by Admin (Salesforce Developers) 
Navatar_DbSupNavatar_DbSup

Hi,

 

You can use the left method for displaying the specific number of character

 

For example:

 

value="{!Left(t.miiHelpDeskT2__Comment__c,50)}"

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

All Answers

Navatar_DbSupNavatar_DbSup

Hi,

 

You can use the left method for displaying the specific number of character

 

For example:

 

value="{!Left(t.miiHelpDeskT2__Comment__c,50)}"

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. 

This was selected as the best answer
DRobi83DRobi83

Thank you, that got me to a better position.