0

I have a custom object called skill_Review and I am creating a list in my controller using:

 List<Skill_Review__c> skillRev  = new List<Skill_Review__c>
    List<Skill_Review__c> results = [SELECT Id,Name,Skill__c,Level__c FROM Skill_Review__c where Interview__c =:review.id ];

I have another list named skillRev of type skill_review_c in my controller. I want to get each field value in result and put it in the skillRev. Basically I would like to clone results list to skillRev. How can I do this? Is there a way to access Skill__c from results in controller like results.Skill_c?

  • question is not very clear. but are you looking for this skillRev.addAll(results) ? This will add all values if result into skillRev list – Ashwani Mar 16 '16 at 5:43
  • How can I get Skill__c from results list in my controller? – SfdcBat Mar 16 '16 at 5:45
  • Can you post some more relevant code to figure out what you are trying to achieve? otherwise, skillRev.addAll(results) is sufficient to add value in skillRev assuming it is a controller variable. – Ashwani Mar 16 '16 at 6:03
3

If you look into documentation

You can use list.clone()

Example

List<Skill_Review__c> results = [SELECT Id,Name,Skill__c,Level__c 
                                    FROM Skill_Review__c 
                                     where Interview__c =:review.id ];
    List<Skill_Review__c> skillRev = results .clone();

Like @Ashwani said you can use addAll() method here

  List<Skill_Review__c> skillRev =new List<Skill_Review__c>();
  skillRev.addAll(skillRev );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.