This can be done throwthrough 2 ways.
site page
site pagetrigger I have done throw trigger. trigger LeadTrigger on Lead (before insert) { Map<String,Id> zipCodeUserMap = new Map<String,Id>(); for(customObject__c custom : [Select id,zipCode, user from customObject__c]) { zipCodeUserMap.put(custom.zipCode,custom.user);
} for(Lead l : Trigger.new) { if(zipCodeUserMap.containsKey(l.zipCode)) { l.Ownerid = zipCodeUserMap.get(l.zipcode) }} } same logic can be implemented in vf page if you need
trigger
I have done through trigger.
trigger LeadTrigger on Lead (before insert) {
Map<String,Id> zipCodeUserMap = new Map<String,Id>();
for(customObject__c custom : [Select id,zipCode, user from customObject__c]) {
zipCodeUserMap.put(custom.zipCode,custom.user);
}
for(Lead l : Trigger.new) {
if(zipCodeUserMap.containsKey(l.zipCode)) {
l.Ownerid = zipCodeUserMap.get(l.zipcode)
}
}
}
same logic can be implemented in vf page if you need