I'm still pretty new when it comes to Apex, so I apologize in advance if this is an easy thing to fix.
I'm trying to create a trigger that auto populates a picklist field in the Lead object, based on a value of a picklist field on the User object. So if the field on the User has a value of 'a', I want a corresponding value in a different field to be populated for any leads that this user creates.
trigger DefaultBusinessDivision on Lead (before insert)
{
Map<String, String> myPickListMap = new Map<String, String> {'a'=>'a', 'b'=>'b',
'c'=>'c', 'd'=>'d', 'e'=>'e','f'=>'f', 'g'=>'g', 'h'=>'h'};
for (Lead a : Trigger.new)
{
a.Business_Division__c = myPickListMap.get(User.Default_Business_Division__c);
}
}
Attempting to save this throws the error "Incompatible key type Schema.SObjectField for MAP", should I use a different type instead of (String, String)? Business_Division__c and Default_Business_Division__c are both picklists and are the fields I need to use to update the field on the lead page.