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
Jason Gelsomino 9Jason Gelsomino 9 

I need to display data from a related list on the Case object in a table on a VF page.

I am fairly new to development and need some assistance displaying data in a table on a VF page. The data is contained in a custom object called medication. The object is a related list to Case. I need to show the medication data in a table that pertains to a specific case. I am pretty sure this can be accomplished relatively easily but I can't seem to figure it out. Any assistance would be helpful? 
Best Answer chosen by Jason Gelsomino 9
Amit Singh 1Amit Singh 1
Hello Jason,

Below is Sample code of VF page which displayes the related contact that are related to particular Account.
<apex:page standardController="Account">
<apex:pageBlock title="Related Contacts">
      <apex:pageBlockSection columns="2">
          
          <apex:pageBlockTable value="{!Account}" var="acc">
              <apex:column headerValue="Account Name">
                  <apex:outputField value="{!acc.Name}"/>
              </apex:column>
              <apex:column headerValue="Contacts">
                  <apex:repeat value="{!acc.Contacts}" var="con">
                      <apex:outputField value="{!con.Name}"/><br/>
                  </apex:repeat>
              </apex:column>
          </apex:pageBlockTable>
      </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>
You just need to use Case as StandardController and medications__r/medications__c as relationship in place of contacts and then you can display the fields as per your requirement then add this VF page as in-line vf page to the case record.

Let me know if this helps :)

Thanks!
Amit Singh

 

All Answers

Amit Singh 1Amit Singh 1
Hello Jason,

Below is Sample code of VF page which displayes the related contact that are related to particular Account.
<apex:page standardController="Account">
<apex:pageBlock title="Related Contacts">
      <apex:pageBlockSection columns="2">
          
          <apex:pageBlockTable value="{!Account}" var="acc">
              <apex:column headerValue="Account Name">
                  <apex:outputField value="{!acc.Name}"/>
              </apex:column>
              <apex:column headerValue="Contacts">
                  <apex:repeat value="{!acc.Contacts}" var="con">
                      <apex:outputField value="{!con.Name}"/><br/>
                  </apex:repeat>
              </apex:column>
          </apex:pageBlockTable>
      </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>
You just need to use Case as StandardController and medications__r/medications__c as relationship in place of contacts and then you can display the fields as per your requirement then add this VF page as in-line vf page to the case record.

Let me know if this helps :)

Thanks!
Amit Singh

 
This was selected as the best answer
Jason Gelsomino 9Jason Gelsomino 9
Amit, 

Thanks so much! That did teh trick....just need to tweek it a bit. 

Thanks, Jason