I have a skill_Review__c object which has two lookup fields in them - Skills__c and Level__c.

Below is my VF and controller. I am trying to get the user input on level field by clicking the edit button VF page and when I save it the level entered by user should be updated to the Level__c on skill_review__c object.

I have created a skillreview list where I store the level__c and skill__c for a particular skill_review__c object. How can I display the skillreviewlist in my VF page and how can I update the level__c record from the value entered from level drop down list.


<apex:page standardController="Interview__c" extensions="SkillReviewExtension" showHeader="false">

  <apex:form >
       <apex:pageBlock title="Technical Skill Evaluation" id="skills_list">

           <apex:pageBlockButtons location="top">
            <apex:commandButton value="Save" action="{!save}"/>
            <apex:commandButton value="Edit" action="{!Edit}"/>

 <apex:pageBlockTable value="{! SkillReviewList }" var="rt" > 
 <apex:column value="{!rt.SkillReview.Skill__c}"/>
 <apex:column value="{! rt.SkillReview.Level__c}"/>
 <apex:column headerValue="Level">
                    <apex:selectList value="{!rt.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"/>

Controller extension:

public class SkillReviewExtension{

    private final Interview__c review;
    public  boolean IsEditMode {get;private set;}
    public String Level{get;set;}
    public List<SkillReview> SkillReviewList{get;set;}

     public SkillReviewExtension(ApexPages.StandardController stdController) {
        this.review= (Interview__c)stdController.getRecord();


    private void initSkillReviews() {
        skillReviewList=new List<skillReview>();

        for(Skill_Review__c sr: [SELECT Id,Name,Skill__c,Level__c FROM Skill_Review__c where Interview__c =:review.id ]){

            skillReviewList.add(new SkillReview(sr));


    public PageReference save(){
        update SkillReviewList[0].SkillReview;
        return null;

    public PageReference edit(){
        return null;


SkillReview class:

public class SkillReview{

    public Skill_Review__c SkillReview{get;set;}

    public String Level{get;set;}

    public SkillReview(Skill_Review__c skillReview){

         this.skillReview = skillReview;
         this.Level = skillReview.Level__c;




Skill_review__c object has skill__c and level__c as a lookup field in it.

  • Rdvsm. if you want the user input then it should be in <apex:inputText value="fieldAPIName" /> this way you can bind the value
    – Ratan Paul
    Mar 17, 2016 at 4:01
  • Do you mean using it like - <apex:selectList value="Level__c" multiselect="false" size="1" rendered="{!isEditMode}"> in VF page? This give an error.
    – SfdcBat
    Mar 17, 2016 at 4:04
  • Just a background - I have a select list on my page with values 1 to 5. When the user select this list and click save on VF page , the level__c object should get updated. This is my requirement.
    – SfdcBat
    Mar 17, 2016 at 4:08
  • sfdcweb- please see the edited VF page.
    – SfdcBat
    Mar 17, 2016 at 4:23
  • Rdvsm -- looks like lebel__c is lookup field. If yes then what should happens you select 1 in picklist and is there any Level__c record with name or something unique 1 ? ... based on selected picklist value we can query the Level__c record Id and then we can assign that Id to SkillReview.Level__c.. after that we can perform Update DML on SkillReview record.
    – Ratan Paul
    Mar 17, 2016 at 4:49

1 Answer 1


Like you said in chat. Level__c records Name field is 1,2,3,4,5

So what you can do

In save method Query Level__c records based on selected picklist value. and then update the Skill review level field with that Id

public PageReference save(){
         //set to add all the picklist level values
        set<String> setLavelNames = new set<String>();
        //iterate over wrapper class and collect all the selected level in set
        for(SkillReview obj: skillReviewList)
            setLavelNames.add(obj.level);// add selected level into set 
        map<String, Id> mapLevelNameToLevelId = new map<String, Id>();
        //query on Level records based on above set and create a map to hold Level Name to Id 
        for(Level__c objLevel:[SELECT Id, Name FROM Level__c WHERE Name IN: setLavelNames])
            // store Name and Id of level in map as key value pair so we can get the Id in next for loop
            mapLevelNameToLevelId.put(objLevel.Name, objLevel.Id);
        // perform update DML outside of for loop
        List<Skill_Review__c > lstSkillReviewToUpdate = new List<Skill_Review__c>();
        for(SkillReview obj: skillReviewList)
            // get the Id from map based on selected picklist value 
            obj.SkillReview.Level__c = mapLevelNameToLevelId.get(obj.level); 
        update lstSkillReviewToUpdate; //update list 
        return null;

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .