I am running a soql query to obtain the value of a specific field from a custom object and it is returning the ID of the record on the visualforce page instead of the field value that I need it to return, the specific query I am having issues with is the Names query on the very bottom. If anyone has any ideas why it's returning the ID of the record instead of the specific field value please let me know.

patient_name__c is the field name that I need to obtain the value from and lead__c is a custom object that we have created.

    public without sharing class LeadAlertController {
    public integer leads {get;set;}
    public integer overleads {get;set;}
    public List<lead__c> Names {get;set;}

    public LeadAlertController() {
        leads = [select count() from lead__c where lead_status__c=:'Not Attempted'];
        overleads=[select count() from lead__c where lead_status__c=:'Not Attempted' AND x10MinAlert__c=:true];
        Names = [select patient_name__c from lead__c where lead_status__c=:'Not Attempted'];


Here is my VF Page

<apex:page controller="LeadAlertController" showHeader="false" sidebar="false" standardStylesheets="false">
<!-- Begin Default Content REMOVE THIS -->
<meta http-equiv="refresh" content="10"/>
    border: 1px ;
    border-style: solid;
<table align="center" style="width:100%;border:1px solid">
        <td align="center">
            <h3>Number of Hot Leads</h3>
        <td align="center">
            <h3>Number of Hot Leads Over 10 Minutes</h3>
         <td align="center">
            <h3>List of Names</h3>
        <td align="center">
        <td align="center">
         <td align="center">

<apex:outputPanel rendered="{!if(OverLeads>0,true,false)}">
    <audio src="/resource/alert" type="audio/mp3" autoPlay="true">

  • What is the datatype of Patient_Name__c? Can you edit your question to show how you are displaying the field on your VF page? – gNerb Oct 1 '19 at 16:35
  • It is a normal text field with a limit of 100 characters, I added my VF page – Edward Sobotka Oct 1 '19 at 16:37
  • Can you system.debug Names to see what it is returning? – Zach Oct 1 '19 at 16:47
  • It's returning the content within the field, the Id, and the record type Id. – Edward Sobotka Oct 1 '19 at 16:50

First thing, I noticed you're using "lead__c" in your query? This should be a standard object so it should simply be "lead".

Assuming your query works, your query is returning a list of Leads that actually contains the Id and RecordTypeId even though you didn't specify it. The VF page, when you simply reference the entire list, doesn't know how to display what you want as you haven't told it to.

You have two options here:

You can do what you did and just loop through the variable in VF and display specific record values.

<apex:repeat var="lead" value="{!names}">
    <apex:outputText value="{!lead.patient_name__c}"/>


You can do more work in the apex controller to have the data like you'd like.

public List<String> Names {get;set;}

for(Lead ld : [select patient_name__c from lead__c where lead_status__c=:'Not Attempted']){
| improve this answer | |
  • This actually isn't a standard object, it is a custom object that we created that shares an API name with Lead, the API name is lead__c – Edward Sobotka Oct 1 '19 at 17:02
  • I used your VF suggestion and it worked like a charm once I edited the lead portion, thank you very much for your help. – Edward Sobotka Oct 1 '19 at 17:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.