You need to sign in to do that
Don't have an account?
VKrish
Help with Map in custom object
Hi All,
I am trying the following:
Map<Id, Account> accMap = new Map<Id, Account>(); Map<Id, Custom__c> cMap = new Map<Id, Custom__c>(); accMap.putAll([select id, Name from Account]); cMap.putAll([select id, cName__c from Custom__c]);
It is working perfectly with Account.
But the last line is giving me error saying Map(List<Custom__c>) is not defined.
Does putAll method works only with standard objects?
What am I missing?
Try this:
Map<Id, Custom_Object__c> myMap = new Map<Id, Custom_Object__c>([Select Custom_Field__c From Custom_Object__c]);
All Answers
Try this:
Map<Id, Custom_Object__c> myMap = new Map<Id, Custom_Object__c>([Select Custom_Field__c From Custom_Object__c]);
It works. Thanks!
Anyway I couldnt understand why putAll method doesnt work with custom objects