You need to sign in to do that
Don't have an account?
West415
Incompatible Element Type error when using add() method for a list
Hi,
I'm getting this error in my code: Save error: Incompatible element type
I'm getting this error in my code: Save error: Incompatible element type
List<Candidate__c> candidateList = new List<Candidate__c>(); Map<String,List<Candidate__c>> candidateMap = new Map<String,List<Candidate__c>>(); ....... candidateList.add( candidateMap.values() );
I did a system.debug() on my map and I see the candidate records. I'm trying to extract the values out from the map and populate my list, but I get the error "Incompatible element type", I thought the values() method would return a list.
Any help appreciated.
Try below code and let me know,
Use AddAll insteadd Add
Best regards,
-Vivek
I am populating the map using this code which includes the addAll()
Any ideas why I'm getting this slightly different error?
Refer below link and let me know if it works.
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_list.htm#apex_System_List_addAll
Try below code.