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
NANCY1NANCY1 

How can I display records with a check box and then update a field from selected record?

Hi All,

 

I am using the wrapper class to achieve the desired functionality..also i am referring the following link:

http://wiki.developerforce.com/index.php/Wrapper_Class

 

also, i am getting the following error:

Compile Error: Invalid field con for SObject RR__c at line 46 column 27

 

please suggest, where am i wrong....


public class AllRRs
{
   
    public class cRR
    { 
         public RR__c con {get; set;} 
         public Boolean selected {get; set;} 
 
         public cRR(RR__c c)
         {
          con = c;
          selected = false;
         } 
    }

   
   
   
    private Proposal__c rrdetail;
    public List<RR__c> propdetail {get; set;}
       
    public AllRRs(ApexPages.StandardController controller)
    {  
        rrdetail=(Proposal__c)controller.getrecord();
        rrdetail = [select id,name,Proposal_RRF__c from Proposal__c where id =: rrdetail.Id] ;
        propdetail = new List<RR__c>();
        RR__c rrlist = new RR__c();
        rrlist.RRF__c = rrdetail.Proposal_RRF__c;
        propdetail.add(rrlist);                             
    }
   
   
    public RR__c[] getRRRecords()
    {
        RR__c[] rrdetail = [select id,name,gPAC__c,RRF__c,Long_Term_Resource_Location__c,Priority__c,Required_Skill__c,RR_Status__c,RM_Phase__c from RR__c where RRF__c =:rrdetail.Proposal_RRF__c];
        return rrdetail;
       
    }
   
    
    public PageReference processSelected()
    {
        List<RR__c> selectedRRs = new List<RR__c>();
        for(RR__c cRR : getRRRecords())
        { 
          if(cRR.selected == true)
          { 
          selectedRRs.add(cRR.con); 
          } 
        }     
            for(RR__c con : selectedRRs)
            { 
              system.debug(con); 
            } 
            return null; 
    }
   
      
    
}

 

 

Best Answer chosen by Admin (Salesforce Developers) 
Ankit AroraAnkit Arora

I think you are confused with the naming conventions.

 

 public RR__c[] getRRRecords()
    {
        RR__c[] rrdetail = [select id,name,gPAC__c,RRF__c,Long_Term_Resource_Location__c,Priority__c,Required_Skill__c,RR_Status__c,RM_Phase__c from RR__c where RRF__c =:rrdetail.Proposal_RRF__c];
        return rrdetail;
       
    }
   
    
    public PageReference processSelected()
    {
        List<RR__c> selectedRRs = new List<RR__c>();
        for(RR__c cRR : getRRRecords())
        { 
          if(cRR.selected == true)
          { 
          selectedRRs.add(cRR.con); 
          } 
        }     
            for(RR__c con : selectedRRs)
            { 
              system.debug(con); 
            } 
            return null; 
    }

When you write getRRRecords() it means it is fetching the result from query on object RRF__c and after that you are fetching cRR.con which is not a field on RRF__c object.

 

I also noticed that cRR is your wrapper class name, and ma pretty sure that you are confused in the names as you have no where used this wrapper class in your code.

 

 

Thanks

Ankit Arora

Blog | Facebook | Blog Page