I have a below query in my controller class:
List<Skill_Review__c> results = [SELECT Id,Name,Skill__c,Level__c
FROM Skill_Review__c where Interview__c =:review.id ];
Skill_Review__c is a custom object and Skill_c and Level__c are lookup fields on this object. How can I get the Level__c and Skill__c from results list?
I tried like - results[0].Level__c ;
but it says there no such expression.
VF pAge( Look for Level):
<apex:page standardController="Interview__c" extensions="SkillReviewExtension" showHeader="false">
<apex:form >
<apex:pageBlock title="Candidate Skill Evaluation" id="skills_list">
<apex:pageBlockButtons location="top">
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Edit" action="{!Edit}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{! SkillReview }" var="ct" >
<apex:column value="{! ct.Skill__c}"/>
<apex:column value="{! ct.Level__c}"/>
<apex:column headerValue="Level">
<apex:selectList value="{!Level}" multiselect="false" size="1" rendered="{!isEditMode}">
<apex:selectOption itemValue="1" itemLabel="1"/>
<apex:selectOption itemValue="2" itemLabel="2"/>
<apex:selectOption itemValue="3" itemLabel="3"/>
<apex:selectOption itemValue="4" itemLabel="4"/>
<apex:selectOption itemValue="5" itemLabel="5"/>
</apex:selectList>
<apex:outputText value="{!Level}"/>
</apex:column>
<apex:column headerValue="Description"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public class SkillReviewExtension{
private final Interview__c review;
public boolean isEditMode {get;private set;}
public String Level{get;set;}
List<SkillReview> skillReviewList;
public SkillReviewExtension(ApexPages.StandardController stdController) {
this.review= (Interview__c)stdController.getRecord();
}
public List<Skill_Review__c> getSkillReview() {
skillReviewList=new List<skillReview>();
List<Skill_Review__c> results = [SELECT Id,Name,Skill__c,Level__c FROM Skill_Review__c where Interview__c =:review.id ];
results.size();
//skillReviewList.skillReview[0]=results.clone();
return results;
}
public PageReference save(){
isEditMode=false;
return null;
}
public PageReference edit(){
isEditMode=true;
return null;
}
}
Level = results[0].level__c
. Note this would give you an id of the level record as you had mentioned these were lookup fields.