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
Ravindar AdminRavindar Admin 

Can we display private object records in visualforce page?

Trail Head 33Trail Head 33
Yes Ravindar, We can display Private object record in VisualForce page.

Make Lead Object as Private at OWD settings and try below code 
 
<apex:page Controller="LeadRecords">
    <apex:form>
        <apex:pageBlock>
        <apex:pageBlockTable value="{!LeadList}" var="l">
            <apex:column  value="{!l.company}"/>
        </apex:pageBlockTable>
            </apex:pageBlock>
    </apex:form>
</apex:page>
 
public class LeadRecords {
    public list<Lead> LeadList{set;get;}
    
    public LeadRecords(){
        LeadList=[select id,company from Lead];
        
    }
}

Mark it as best Answer if it helps you.

Thanks ,
karthik