So I'm new to Sales force and I was recently given a requirement to populate a field in a my Sampling_c object from my RSM_c field which is in my User Object. This seems very straight forward but I wanted to double check my logic. So my thinking was
-Populate a userMap with the current users information with all the required information. So my question is how do I do that without populating the map with every single user in my User Object. I'll post my current code.
trigger SampleRVBAutoPop on Sampling__c (before insert,after update) {
//Generating User data.
user Users;
Map<String, User> userMap = new Map<String, User>();
List<user> userList = [select id, Name, isActive,RSM__c from User where isActive=true];
for(user u: userList){
userMap.put(u.Name, u);
}
system.debug('**userMap*'+userMap);
for(Sampling__c s :Trigger.new){
}
}
So if I'm not going in the right direction, how do I populate my Map with ONLY the current users information? Thanks.
Update** So believe this should work, I updated it after looking at that link provided by Mark. Opinions?
User userObj=[Select u.UserType,u.UserRoleId,u.LastName, u.Id,u.RSM__c, u.FirstName, u.ISR__c, UserRole.Name,UserRole.ParentRoleId From User u
where u.id=:userinfo.getUserId()];
Now after this I need to create a
List<User> lstParentUserObj= new List<User>
is that the general jist?