Skip to main content

This can be done throwthrough 2 ways.

  1. site page

    site page
  2. trigger 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

This can be done throw 2 ways.

  1. site page

  2. trigger 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

This can be done through 2 ways.

  1. site page
  2. 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

Source Link
S B
  • 543
  • 4
  • 13

This can be done throw 2 ways.

  1. site page

  2. trigger 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