What I am trying to do here is populate a list from a callout to Looker (BI Tool) then create a Map of Salesforce Account IDs to associated Contact Emails. To do this I created this method:

public static Map<Id, List<Contact>> lookerById() {
   List<Contact> lookerList = zuoraContactSync.mergeList();
   Map<Id, List<Contact>> lookerByIds = new Map<Id, List<Contact>>();
   for(Contact con : lookerList) {
           List<Contact> contacts = lookerByIds.get(con.Email);
           lookerByIds.put(con.AccountId, contacts);      
       //status__c is ROLE

   return lookerByIds;

   return lookerByIds;

When I use the put on this line :

lookerByIds = put(con.AccountId, contacts);

I am returned with an incorrect method signature error.

Method does not exist or incorrect signature: void put(Id, List<Contact>) from the type ClassName

I am reasonably certain I have the right logic to do this... mostly. What am I missing?

  • You should be doing lookerByIds.put(con.AccountId, contacts); This should solve your issue. – Arnold Jr. Sep 4 '19 at 19:32
  • Always the small stuff. Seems my if comparison is also off as it returns 0. – Randy B. Sep 4 '19 at 19:45
  • Yes, it would get you 0 as you have initialized lookerByIds at line #3 and haven't assigned any values. Check your business logic to make sure you are comparing a Map/List that contains your Account Ids. – Arnold Jr. Sep 4 '19 at 19:49
  • The list comes from an external source and contains only the SFDC Account Id and the contact Email. The goal is to compare the emails provided to existing contacts for a given account Id and then create a new contact for it if it does not exist. I have revised it to assign values now but the ID is invalid as I have no contactID to provide it. – Randy B. Sep 4 '19 at 19:55
  • You would get another error message as your Line #6 doesn't have any records as you have created lookerByIds at line #3 and didn't assign any values. I would reassess the business need and try to implement step-by-step. This way, we could get more control on the data that is being retrieved. Try going through: Apex documentation. – Arnold Jr. Sep 4 '19 at 20:35

Your Answer

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

Browse other questions tagged or ask your own question.