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
Akash SilAkash Sil 

How to Concatenate multiple field values of the Object and Display it on VF Rich text field?

Hello everyone! I am trying to create a Rich text Field using VF Page where I can use conditions for checkboxes to retreive the values of text fields from "Case" standard object and populate it in the Rich Text Field area by using a custom action button. I am not experienced in Apex coding therefore seeking out for help in correcting my codes.

VF Page: 

<apex:page standardController="Case" extensions="textEditorcontroller" action="{!getautopopulatevalue}" >
    <apex:form >
    <apex:outputPanel style="padding:50px 50px 50px 50px" id="userDetail">
    <apex:outputText rendered="true">
    <div style="color:black;font-size: 15px;font-weight: bold;align-content: center;margin-top: 10px; margin-left: 10px">
    
  
     </div>
     </apex:outputText>
     <apex:pageBlock >
       <apex:pageBlockTable value="{!Case}" var="CS"> 
       
       </apex:pageBlockTable>
      </apex:pageBlock>
     
       
       
  <div style = "margin-left: 20px; margin-top: 10px">
    <apex:commandButton id="AddProofs" value="AddProofs" action="{!getautopopulatevalue}" />
   
    </div>
    <!--<div style = "margin-left: 10px; margin-top: 10px">-->
    
    
    <apex:inputTextarea id="Richtextarea" richText="true" value="{!Allproofs}"/>
   
 
  </apex:outputPanel>
  </apex:form>
    
</apex:page>

APEX Controller:

public class textEditorcontroller{

    
    public Case cs{get;set;}
    public List<Case> Allproofs{get;set;}
    public List<Case> csValue {get;set;}
    public textEditorController (Apexpages.StandardController stdController){
 
    
    this.cs = (Case)stdController.getrecord();
    }
    
    
    public void getautopopulatevalue(){
    
    
                    
               csValue = ([SELECT Document_1__c,Document_1_Comments__c FROM Case 
                                        WHERE Case.Id = :cs.Id]);
                       
                    Allproofs = csValue;
                         
                         
                        
                   }
    
     
      }


Thanks
Gabriel C FerreiraGabriel C Ferreira
Hi Akash,

You just have to change the type of your AllProofs variable and assign it correctly in your controller:
public class textEditorcontroller{

    public Case cs{get;set;}
    public String Allproofs{get;set;}
    public List<Case> csValue {get;set;}

    public textEditorController (Apexpages.StandardController stdController){
        this.cs = (Case)stdController.getrecord();
    }

    public void getautopopulatevalue(){                
        csValue = ([SELECT Document_1__c,Document_1_Comments__c FROM Case WHERE Case.Id = :cs.Id]);
        if (csValue.size() != 0)
            this.Allproofs = 
                csValue.get(0).Document_1__c + 
                ' ' +   // You may use any delimiter here
                csValue.get(0).Document_1_Comments__c;
    }
}

And in your visualforce, you have to tell the page to rerender the richTextField to get the new value of variable:
<apex:commandButton id="AddProofs" value="AddProofs" action="{!getautopopulatevalue}" rerender="Richtextarea"/>

If it helped solve your issue, please mark as the best answer.
Best Regards.
Akash SilAkash Sil
Thanks Gabriel and Apologies for the late response.