You need to sign in to do that
Don't have an account?
Manohar kumar
how to get map<user, List<lead>>()
Hi Team,
i am trying to get map<user, List<lead>>(), List of lead is records created by the user. I think query for getting related list will not work here.
How do i achieve this.
Thanks,
Manohar
Sorry there is no Map.contains() function
Use
AllLeadGroupedMap.containsKey(indLead.createdById).
I have verified the code.It is working fine.
Let me know if you need further help.
Thanks and Regards,
Shiva RV
All Answers
Using of Sobject as the key is not generally appreciated approach ,better use userId.
Do go through the following link if you want to use that pattern
Sobject map key (https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_map_sobject_considerations.htm)
I have used user Id in here instead of using User as Key.
But i have created a map of user with id , so user details can be obtained easily instead of querying
Let me know if you need further help.
Thanks and Regards,
Shiva RV
Hi Shiva,
Thanks for the reply. When i try to run that code in my developer console. it gave me some error. Can't figure out why.
ran through execute anonymous, error is
Method does not exist or incorrect signature: void contains(Id) from the type Map<Id,List<Lead>>
Thanks,
Manohar
Sorry there is no Map.contains() function
Use
AllLeadGroupedMap.containsKey(indLead.createdById).
I have verified the code.It is working fine.
Let me know if you need further help.
Thanks and Regards,
Shiva RV