Map Custom fields of Leads in Salesforce

If you want a simple design, essentially I would do it in a static mapper class. We definitely need more information to help you, but short of that, here is some psuedocode (not production code) that should be a sufficient design pattern.

public static class CustomMapper
{
    public static void leadToContact(Lead lead, ID contactID)
    {
        var contact = new Contact(contactID);
        ///do mapping here
        ///eg
        ///returnval.Newsletter__c = Lead.Newsletter__c;

        contact.save();
    }
}

then for the usage:

//convert the lead to a contact prior to usage here, and get the resulting contact id
CustomMapper.leadToContact(myOldLead, myContactID);

If you perform the conversion, then immediately after perform the custom mapping with an update, then it will seem instantaneous to the users anyways. Without more information, this is the best, generic design pattern that I could recommend.

Leave a Comment