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
LJanikLJanik 

Simple Query - No fields shown

I have a simple query of a custom object.  It is showing the correct number of records(3), but the fields are blank.

 

 

Public List<TestObject__c> specialists;

 

public List<TestObject__c> getSpecialists() { return specialists; } public PageReference search(){ specialists = Database.query('select AnimalType__c from TestObject__c'); return null; }

 

 

 

 

<apex:form > <apex:commandButton action="{!search}" value="Search" /> </apex:form> <apex:dataList var="s" value="{!specialists}" id="list"> Type: <apex:outputText value="{!s.AnimalType__c}" /> </apex:dataList>

 


 

Best Answer chosen by Admin (Salesforce Developers) 
LJanikLJanik

Issue resolved.  This was not an Apex problem, but a Force.com Sites problem. 

 

In the Sites profile, modify Public Access Settings.  Edit Custom Object Permissions and check READ for Basic Access for the custom object.

All Answers

AmphroAmphro
That code works fine for me. Is it just showing 3 "Type:" with nothing after it? Are you sure the AnimalType__c field isn't blank?
LJanikLJanik
No the field is not blank.  I am trying to use this with a Sites implementation.  I checked the Field Accessibility, and it is editable. 
AmphroAmphro

Hmm, I have a feeling it has to do with your objects because the code seems fine. Here is what I did, maybe it will help you debug.

  • Create Test_Object__c
  • Create test field Animal_Test__c on Test_Object__c
  • Create tab for Test_Object__c
  • Create 2 Test_Object__c records, with Test1 and Test2 in their Animal_Test__c fields.
  • Create the Specialties class
  • Create the test page

Apex Class:

public class specialties {  
Public List specialists;

public List getSpecialists() {
return specialists;
}

public PageReference search(){
specialists = Database.query('select Animal_Type__c from Test_Object__c');
return null;
}
}

VisualForce Page:

<apex:page controller="specialties">
<apex:form >
<apex:commandButton action="{!search}" value="Search" />
</apex:form>

<apex:dataList var="s" value="{!specialists}" id="list">
Type: <apex:outputText value="{!s.Animal_Type__c}" />
</apex:dataList>
</apex:page>

Results:

  • Type:Test1
  • Type:Test2

 

Hope that helps

LJanikLJanik

I'm stumped.  Seems like a permission problem?  Here is my Sites link:

 

http://free-12352c25bf4.force.com/Test1/TestPageA

LJanikLJanik

Issue resolved.  This was not an Apex problem, but a Force.com Sites problem. 

 

In the Sites profile, modify Public Access Settings.  Edit Custom Object Permissions and check READ for Basic Access for the custom object.

This was selected as the best answer