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
SFDC8899SFDC8899 

apex html body


I have a text area field. Field will insert as

apple | Bat | Cat

I need as 

apple

bat

cat

and same like i need to add email body.

 

Best Answer chosen by SFDC8899
ManojSankaranManojSankaran
Hi Hemanth,

acc = new Account();
        acc = [select id,description from account where id =: controller.getRecord().id];
        system.debug(acc.description);
        List<string> tempList = new List<String>();
        tempList = (acc.description.split('\r\n'));
        system.debug(tempList.size());
        String FinalString;
        for(string s : TempList){
            if(FinalString == ''){
                FinalString = s;
            }else
                FinalString = FinalString + '\n' + s;
            
        }


This code will split the description from account object and the final string will have a values with newlines inbetween the values


Thanks
Manoj S

All Answers

ManojSankaranManojSankaran
Hi Hemanth,

I am not clear on the question. Can you please elobrate.

Assumption
1. You have a text area field in an object 
2. You are trying to display that field in a VF Page and in Email Body

Solution
1. Enter the values in long text area as per your requirement. Each value in a new line.
2. Display the field in VF Page using apex:output field 


This works fine for me. If my understanding is worng let me know. If it solves your query mark it as answer.

Thanks
Manoj S

 
ManojSankaranManojSankaran
Hi Hemanth,

acc = new Account();
        acc = [select id,description from account where id =: controller.getRecord().id];
        system.debug(acc.description);
        List<string> tempList = new List<String>();
        tempList = (acc.description.split('\r\n'));
        system.debug(tempList.size());
        String FinalString;
        for(string s : TempList){
            if(FinalString == ''){
                FinalString = s;
            }else
                FinalString = FinalString + '\n' + s;
            
        }


This code will split the description from account object and the final string will have a values with newlines inbetween the values


Thanks
Manoj S
This was selected as the best answer