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
yeshiwork Mohammedyeshiwork Mohammed 

How to list custom object data on case

Hi All,
I have a requirement to display a list of licenses associated to customer account on a case object. How will I achieve that ? here is the detail

I have deployed_licenses__c custom object that is in parent-child relation to Account object (a customer may have different kinds of licenses with different version). Our support would like to see the list of licenses that customer account have on the case page as a related list. They do not want to go to Account page to see the liocenses. Account is a lookup field on the case object. 
Thank You
YM

 
Best Answer chosen by yeshiwork Mohammed
Abdul KhatriAbdul Khatri
You can user Visualforce Page to achieve your requirement. Here are the details

Contoller Class
public class CaseStandardControllerExtension {

    Case caseRecord;

    public CaseStandardControllerExtension(ApexPages.standardController std) {
        
        caseRecord = (Case)std.getRecord();
    }
    
    public List<Deployed_Licenses__c> getAccountDeployedLicenses() {
    
        return [SELECT Name, Account__c FROM Deployed_Licenses__c WHERE Account__c = :caseRecord.AccountId];
    
    }
}

Visualforce Page
<apex:page standardController="Case" extensions="CaseStandardControllerExtension">

    <apex:form >
        <apex:pageBlock >
            <apex:pageblockTable value="{!AccountDeployedLicenses}" var="ado">
                <apex:inputHidden value="{!case.AccountId}"/>
                <apex:column value="{!ado.Name}" />
                <apex:column value="{!ado.Account__c}"/>
            </apex:pageblockTable>
            </apex:pageBlock>
    </apex:form>
    
</apex:page>

On the Case Layout, just add a Section and add a Visualforce Page. It will look something like this

User-added image

Let me know if it help.

Please don't forget to mark it best if helped.

All Answers

Abdul KhatriAbdul Khatri
You can user Visualforce Page to achieve your requirement. Here are the details

Contoller Class
public class CaseStandardControllerExtension {

    Case caseRecord;

    public CaseStandardControllerExtension(ApexPages.standardController std) {
        
        caseRecord = (Case)std.getRecord();
    }
    
    public List<Deployed_Licenses__c> getAccountDeployedLicenses() {
    
        return [SELECT Name, Account__c FROM Deployed_Licenses__c WHERE Account__c = :caseRecord.AccountId];
    
    }
}

Visualforce Page
<apex:page standardController="Case" extensions="CaseStandardControllerExtension">

    <apex:form >
        <apex:pageBlock >
            <apex:pageblockTable value="{!AccountDeployedLicenses}" var="ado">
                <apex:inputHidden value="{!case.AccountId}"/>
                <apex:column value="{!ado.Name}" />
                <apex:column value="{!ado.Account__c}"/>
            </apex:pageblockTable>
            </apex:pageBlock>
    </apex:form>
    
</apex:page>

On the Case Layout, just add a Section and add a Visualforce Page. It will look something like this

User-added image

Let me know if it help.

Please don't forget to mark it best if helped.
This was selected as the best answer
yeshiwork Mohammedyeshiwork Mohammed
Thank you so much.