0

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();
   system.debug(lookerList);
   Map<Id, List<Contact>> lookerByIds = new Map<Id, List<Contact>>();
   for(Contact con : lookerList) {
           List<Contact> contacts = lookerByIds.get(con.Email);
           system.debug(lookerByIds);
           lookerByIds.put(con.AccountId, contacts);      
       }                 
       //status__c is ROLE

   system.debug(lookerByIds.size());
   system.debug(lookerByIds);
   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?

5
  • You should be doing lookerByIds.put(con.AccountId, contacts); This should solve your issue.
    – SatyaV
    Commented Sep 4, 2019 at 19:32
  • Always the small stuff. Seems my if comparison is also off as it returns 0.
    – Randy B.
    Commented Sep 4, 2019 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.
    – SatyaV
    Commented Sep 4, 2019 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.
    Commented Sep 4, 2019 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.
    – SatyaV
    Commented Sep 4, 2019 at 20:35

0

You must log in to answer this question.

Browse other questions tagged .