You need to sign in to do that
Don't have an account?
Koustubh Kulkarni
I cant retrieve list of records from the custom object on VF page?
Hi,
I have one custom object named EmplyeeTopicRating__c is on detail side of contact standard object.Based on the name of contact i want to fetch list of records from EmplyeeTopicRating__c. so i have written custom controller for it.It didnt give me any error but it doesnt fetches values on EmplyeeTopicRating__c object.so please give me solution.
**************my controller***********************************
public class contactextention
{
public contact cont{get;set;}
public PageReference save()
{ update cont;
return null;
}
public contactextention() {
String acctId = ApexPages.currentPage().getParameters().get('id');
cont = [Select Name From contact Where Id = :acctId];
}
public list<EmplyeeTopicRating__c> ratings1
{ get {
ratings1 =[select Employee_name__c,Employee_name__r.ContactRole__r.Name,TopicPriorityRecord__r.Priority__c,quarter__c,Ratings__c,Year__c,
TopicPriorityRecord__r.Topic_Name__r.Group_Name__r.Name,TopicPriorityRecord__r.Topic_Name__r.Name from EmplyeeTopicRating__c where Employee_name__c=:cont.name];
return ratings1;
}
set;
}
public String getGreeting()
{
return 'Hello ' + cont.name + ' (' + cont.id + ')';
}
}
*******************VF page***********************
<apex:page controller="contactextention">
{!Greeting}
<apex:form >
<Apex:pageBlock >
<apex:pageblockButtons >
<apex:commandButton action="{!save}" value="save" />
</apex:pageblockButtons>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!ratings1}" var="etr">
<apex:column headerValue="Year">
<apex:inputField value="{!etr.Year__c}"/>
</apex:column>
<apex:column headerValue="Quarter">
<apex:outputField value="{!etr.quarter__c}"/>
</apex:column>
<apex:column headerValue="Role name">
<apex:outputField value="{!etr.TopicPriorityRecord__r.Role__r.Name}"/>
</apex:column>
<apex:column headerValue="Priority no">
<apex:outputField value="{!etr.TopicPriorityRecord__r.Priority__c}"/>
</apex:column>
<apex:column headerValue="Ratings">
<apex:inputField value="{!etr.Ratings__c}"/>
</apex:column>
<apex:column headerValue="Topic Name">
<apex:outputField value="{!etr.TopicPriorityRecord__r.Topic_Name__r.Name}"/>
</apex:column>
</Apex:pageblockTable>
</apex:pageBlockSection>
</Apex:pageBlock>
</apex:form>
</apex:page>
please show whats wrong in the code
I have one custom object named EmplyeeTopicRating__c is on detail side of contact standard object.Based on the name of contact i want to fetch list of records from EmplyeeTopicRating__c. so i have written custom controller for it.It didnt give me any error but it doesnt fetches values on EmplyeeTopicRating__c object.so please give me solution.
**************my controller***********************************
public class contactextention
{
public contact cont{get;set;}
public PageReference save()
{ update cont;
return null;
}
public contactextention() {
String acctId = ApexPages.currentPage().getParameters().get('id');
cont = [Select Name From contact Where Id = :acctId];
}
public list<EmplyeeTopicRating__c> ratings1
{ get {
ratings1 =[select Employee_name__c,Employee_name__r.ContactRole__r.Name,TopicPriorityRecord__r.Priority__c,quarter__c,Ratings__c,Year__c,
TopicPriorityRecord__r.Topic_Name__r.Group_Name__r.Name,TopicPriorityRecord__r.Topic_Name__r.Name from EmplyeeTopicRating__c where Employee_name__c=:cont.name];
return ratings1;
}
set;
}
public String getGreeting()
{
return 'Hello ' + cont.name + ' (' + cont.id + ')';
}
}
*******************VF page***********************
<apex:page controller="contactextention">
{!Greeting}
<apex:form >
<Apex:pageBlock >
<apex:pageblockButtons >
<apex:commandButton action="{!save}" value="save" />
</apex:pageblockButtons>
<apex:pageBlockSection >
<apex:pageBlockTable value="{!ratings1}" var="etr">
<apex:column headerValue="Year">
<apex:inputField value="{!etr.Year__c}"/>
</apex:column>
<apex:column headerValue="Quarter">
<apex:outputField value="{!etr.quarter__c}"/>
</apex:column>
<apex:column headerValue="Role name">
<apex:outputField value="{!etr.TopicPriorityRecord__r.Role__r.Name}"/>
</apex:column>
<apex:column headerValue="Priority no">
<apex:outputField value="{!etr.TopicPriorityRecord__r.Priority__c}"/>
</apex:column>
<apex:column headerValue="Ratings">
<apex:inputField value="{!etr.Ratings__c}"/>
</apex:column>
<apex:column headerValue="Topic Name">
<apex:outputField value="{!etr.TopicPriorityRecord__r.Topic_Name__r.Name}"/>
</apex:column>
</Apex:pageblockTable>
</apex:pageBlockSection>
</Apex:pageBlock>
</apex:form>
</apex:page>
please show whats wrong in the code
Employee_name__c but instead of using '__c' i should have used '__r' as it has master detail relationship with contact.Thanks
All Answers
1. make sure this is valid and returning values.
2. make sure this cont.name variable is returning any values.
https://workbench.developerforce.com/login.php
TopicPriorityRecord__r.Topic_Name__r.Group_Name__r.Name,TopicPriorityRecord__r.Topic_Name__r.Name from EmplyeeTopicRating__c where Employee_name__c='sandesh Ganjare'
Employee_name__c but instead of using '__c' i should have used '__r' as it has master detail relationship with contact.Thanks