You need to sign in to do that
Don't have an account?

How to replace a CaseComment item with string and send to a table
I have the following code. I would like to replace the CreatedBy.Name field with some text when it matches and automated account we have.
What would be the best way to replace this, send it to a list so I can then use that list in my pageBlockTable.
Thanks.
What would be the best way to replace this, send it to a list so I can then use that list in my pageBlockTable.
public my_Test_Apex(ApexPages.StandardController stdController) { this.myCase = (Case)stdController.getRecord(); //get case comments Case com = [select Id, CaseNumber,(select ParentId,CommentBody,CreatedDate,CreatedBy.Name from CaseComments ORDER BY CreatedDate DESC) from Case where Id =: ApexPages.CurrentPage().getParameters().get('Id') ]; caseCommentList = new List<CaseComment>(); for(CaseComment cs : com.CaseComments) { if(cs.CreatedBy.Name.contains('NameToReplace')) { //replace 'NameToReplace' with 'Support Representative' } else { caseCommentList.add(cs); } } }
Thanks.
Thanks Lokesh for getting me on the right path!
All Answers
You can refine your code to get list of case comments something like this This list can be referenced in VF pageblocktable
Refer this example link
https://help.salesforce.com/articleView?id=000205631&type=1
Lokesh...
If get your issue correctly, you are trying to manipulate query data before displaying in VF page, if so, you need to use wrapper class. something like this. Refer csList in your VF page.
I've been trying to build a wrapper as you suggested, but can't seem to get my page to even return a case number in my table, much less any comment information.
Can you spot anything that I'm doing wrong?
***My VF page***
***My Apex Code***
Thanks Lokesh for getting me on the right path!