標準の関連リストはカスタマイズできません。この機能を取得するには、Visualforce を使用してカスタム関連リストを作成し、ページレイアウトに埋め込む必要があります。これを行うには、関連レコードをクエリして表示してから、ユーザーの入力を取り込んで関連レコードを更新するカスタムアクションを作成します。関連リストをカスタマイズする方法を以下に記載します。
標準の保存機能は、保存後にページをリダイレクトするため、使用できません。次のサンプルコードをケースページレイアウトに埋め込むと、ユーザーがケースコメントの isPublished 値を変更できるようになります。
サンプルコード : Visualforce ページ
<!-- これはケースコメント(CaseComment)関連リストを表示するカスタム Visualforce ページです。ユーザーがケースコメントの isPublished の値を変更できる入力項目もあります。
このページをケースページレイアウトに埋め込みます。 -->
<apex:page standardcontroller="case" extensions="checkbox" tabstyle="case">
<apex:pageBlock title="Case Comments" mode="new" >
<apex:form >
<apex:commandButton value="Save" action="{!customSave}"/> <!-- これは、カスタム Save ボタンです -->
<apex:pageBlockTable value="{!Records}" var="index"> <!-- pageBlockTable はカスタムクラスのリストを介して動作します -->
<apex:column > <apex:inputCheckbox value="{!index.published}"/> </apex:column> <!-- ユーザーが入力した値を保存します -->
<apex:column value="{!index.comment.isPublished}"/> <!-- ケースコメントの内容を表示 -->
<apex:column value="{!index.comment.CommentBody}"/>
</apex:pageblocktable>
</apex:form>
</apex:pageBlock>
</apex:page>
サンプルコード : Apex クラス
public class checkbox {
public class AssignComment //このクラスは、ユーザーおよびケースコメントからの対応する入力を保存するために使用されます。
{
public CaseComment comment {get; set;} //これはケースコメントを保存します。
public Boolean published {get; set;} //これはユーザーの入力を保存します。
public AssignComment(){} //空のコンストラクタ
}
public List<assignComment> Records {get; set;} //これは、対応するユーザーの入力と同様に、ケースコメントを保存します。
public checkbox(ApexPages.StandardController controller)
{
Records = new List<AssignComment>();
Case Record = (Case) controller.getRecord(); //Controller からケースを取得します。
for (CaseComment Node : [Select commentBody, isPublished from CaseComment where parentId = :Record.Id]) //すべてのケースコメントをクエリしてループします。
{
assignComment temp = new AssignComment(); //リストに挿入する一時レコードを作成します。
temp.comment = Node;
temp.published = Node.isPublished;
Records.add(Temp);
}
}
public PageReference CustomSave() //このクラスは、ユーザーの入力を受け取り、対応するケースコメントを更新します。
{
List<CaseComment> updateList = new List<CaseComment>(); //更新するケースコメントのリストを作成します。
for (AssignComment a : Records) //レコードを介してループします。
{
a.comment.isPublished = a.published; //ユーザーの入力によってケースコメントを更新します。
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.