You need to sign in to do that
Don't have an account?

Need More information on Maps and map lookups
I'm working to try to fully understand how Maps and map lookups work. I've read all the documentation I can get my hands on, but that doesn't seem to help.
Here's an example Map called userMap:
<Name(String), UserID(User)>
<Mike, 00123456abc>
<Tim, 000123832abc>
<Jake, 00123999jam>
If I want to know what Tim's UserID is, how would I get that information?
My first impression of maps would be to use something like: userMap.get(Tim).UserID
But based on Simon's post on a recent thread it seems like the key that you have to use to do the lookup is actually different.
Can anyone explain how Map keys actually work?
Here's an example Map called userMap:
<Name(String), UserID(User)>
<Mike, 00123456abc>
<Tim, 000123832abc>
<Jake, 00123999jam>
If I want to know what Tim's UserID is, how would I get that information?
My first impression of maps would be to use something like: userMap.get(Tim).UserID
But based on Simon's post on a recent thread it seems like the key that you have to use to do the lookup is actually different.
Can anyone explain how Map keys actually work?
User tmpUser = userMap.get('Tim');
I'm trying to get the actual User ID out of it, so I'm doing something like:
Lead newLead.OwnerID = userMap.get("Tim").UserID
Or how else should I get just the ID back? I don't need the whole object.
Lead newLead.OwnerID = userMap.get("Tim").Id
There is no field 'UserId' on the User object.
When you do the 'get' from the Map object, it returns the User object. And then you can use the 'dot notation' to get User fields. And UserId is not a valid field.
Thanks,
Andrew