3

When a Lead is converted, the "Description" of the lead is going to the "Description" of the newly created contact. If I convert a Lead into an existing contact, then the "Description" of the lead goes nowhere. to add the Description of this lead to existing Description of the existing contact?

3

You could write a trigger on the Lead object. You would need to check that the lead has been converted and it was converted to an existing Contact. then you could append or replace the description on your Contact, whatever you want.

Something like this

trigger LeadTrigger on Lead (after update) {

    map<Id,Contact> conMap = new map<Id,Contact>();

    for(Lead l : trigger.new){
        if(l.isConverted == true && trigger.oldMap.get(l.Id).isConverted == false){
            if(l.ConvertedContactId != null){
                conMap.add(ConvertedContactId,null);
            }
        }
    }
    conMap.addAll([Select Id, Name, Description From Contact Where Id In: conMap.keyset()]);

    for(Lead l : trigger.new){
        if(conMap.containsKey(l.ConvertedContactId)){
            //This is where you could do what you want with the lead description.
            //This is just replacing it, but you can do what you like.
            conMap.get(l.ConvertedContactId).Description = l.Description;
        }
    }
    update conMap.values();
}
  • or you could just use the '+' sign. it concatenates the whole string. but you'll have to check. – Sam Oct 28 '13 at 11:06
  • Correct, you could concatenation the description instead of just replacing it – Chris Duncombe Oct 28 '13 at 11:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.