Since a standard related list cannot be customized, you'll need to create a custom related list using Visualforce and embed it into the Page Layout. This can be done by querying and displaying the related records, then creating a custom action which takes the input from the User and updates the related records. Learn how you can accomplish these steps using the example below.
The standard "save" functionality cannot be used since it redirects the page after the save. The sample code below can be embedded into a Case Page Layout and allows Users to modify the "isDisplayed" value of the Case Comments.
Sample Code : Visual force page:
<!-- This is a Custom VisualForce page that will display the CaseComments related list.
It also has input field for the user to change the value of isPublished on CaseComments.
Embed this page into a Case Page Layout -->
<apex:page standardcontroller="case" extensions="checkbox" tabstyle="case">
<apex:pageBlock title="Case Comments" mode="new" >
<apex:form >
<apex:commandButton value="Save" action="{!customSave}"/>
<!-- This is the Custom Save Button -->
<apex:pageBlockTable value="{!Records}" var="index">
<!-- The pageBlockTable iterates through the list of the custom Class -->
<apex:column > <apex:inputCheckbox value="{!index.published}"/> </apex:column> <!-- Stores the input value from the user -->
<apex:column value="{!index.comment.isPublished}"/>
<!--Display the CaseComments information -->
<apex:column value="{!index.comment.CommentBody}"/>
</apex:pageblocktable>
</apex:form>
</apex:pageBlock>
</apex:page>
Sample Code : Apex Class
public class checkbox {
public class AssignComment
// This class will be used to store the corresponding input from the user and the CaseComment.
{
public CaseComment comment {get; set;} //This will store the CaseComment.
public Boolean published {get; set;} //This will store the input from the user.
public AssignComment(){} //Empty constructor.
}
public List<assignComment> Records {get; set;}
//This will store the list of CaseComments as well as the corresponding user inputs.
public checkbox(ApexPages.StandardController controller)
{
Records = new List<AssignComment>();
Case Record = (Case) controller.getRecord();
//Get case from controller.
for (CaseComment Node : [Select commentBody, isPublished from CaseComment where parentId = :Record.Id])
//Query and loop through all the CaseComments.
{
assignComment temp = new AssignComment();
// Create temp to insert into the list Records.
temp.comment = Node;
temp.published = Node.isPublished;
Records.add(Temp);
}
}
public PageReference CustomSave()
//This class will take the input from the user and update the corresponding CaseComments.
{
List<CaseComment> updateList = new List<CaseComment>();
//Create a list of CaseComments to be updated.
for (AssignComment a : Records) //Loop through Records.
{
a.comment.isPublished = a.published;
//Update CaseComments with user input.
updateList.add(a.comment);
}
update(updateList);
return null;
}
}
000384992

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.