You need to sign in to do that
Don't have an account?
Ayan Sarkar
Getting SOQL results into MAP
For example... I have a SOQL query :-
[SELECT name, profile.name, email, isActive from User where UserRoleId in (SELECT ID from UserRole WHERE name in ('CEO','COO','ALC Midwest','ALC Southwest'))];
Now each role may have more than one users.
So, My requirement is that I want a map with key = UserRoleID and value = list of all users under that role.
So is it possible to do this without looping the above query's result and then putting values into map
Or some GROUP BY clause (or something else) can help me do this efficiently..
If nothing is possible and only looping is the only way then please provide an efficient and optimized code than the normal one-by-one row looping.
Help me its urgent
[SELECT name, profile.name, email, isActive from User where UserRoleId in (SELECT ID from UserRole WHERE name in ('CEO','COO','ALC Midwest','ALC Southwest'))];
Now each role may have more than one users.
So, My requirement is that I want a map with key = UserRoleID and value = list of all users under that role.
So is it possible to do this without looping the above query's result and then putting values into map
Or some GROUP BY clause (or something else) can help me do this efficiently..
If nothing is possible and only looping is the only way then please provide an efficient and optimized code than the normal one-by-one row looping.
Help me its urgent
See if following code helps.
All Answers
See if following code helps.