2

I have a large amount of custom fields under leads, and now we want to make some of those people into contacts. Is there a way to copy the custom fields to contacts, so I don't have to recreate them all?

Thanks!

Edit: I'm looking at the Eclipse Force.com IDE now.

5
  • Are you wanting to copying the custom field definition from the Lead object to the Contact object, or are you wanting to copy record data from a Lead to a Contact during lead conversion? (or both)
    – Mark Pond
    Commented Sep 10, 2013 at 15:33
  • Really both, but I was asking about the custom field definitions. Can they both be done at once?
    – user3515
    Commented Sep 10, 2013 at 15:37
  • 1
    The mapping of custom field data from Lead to Contact during lead conversion is defined in Customize | Leads | Fields | Map Lead Fields in the org. Salesforce Docs: Mapping Custom Lead Fields
    – Mark Pond
    Commented Sep 10, 2013 at 16:07
  • If I go that route do I need to create the fields in Contacts first?
    – user3515
    Commented Sep 10, 2013 at 17:16
  • Yes the fields need to exist on the Contact object first, then you can perform the mapping between the Lead fields and your Contact fields. This map will be used during conversion from Lead to Contact.
    – Mark Pond
    Commented Sep 10, 2013 at 17:18

2 Answers 2

4

Using Eclipse you can retrieve the metadata for Objects in your org and then copy and paste the field definitions which you don't want to recreate manually and then save the changes.

You would then need to set the security on these newly added fields on the Contact object.

For Example, if you had a custom field on the Lead object for Preferred Phone Number, in the XML file Lead.object contained within [Your Project] -> src -> objects in Eclipse you will find the field defined similarly to this:

<fields>
    <fullName>PreferredPhoneNumber__c</fullName>
    <externalId>false</externalId>
    <label>Preferred Phone Number</label>
    <required>false</required>
    <trackFeedHistory>false</trackFeedHistory>
    <type>Phone</type>
</fields>

In order to copy this field to the Contact object, simply copy and paste this XML structure of the field definition into the Contact.object XML file in the appropriate location (where all of the other fields are defined) and then save the Contact.object file.

If you have not included the objects folder in your force.com project hierarchy, you can add it by selecting "Add/Remove Metadata Components..." from the force.com menu or Project Properties -> force.com -> Project Contents -> Add/Remove

4
  • Cool! I followed your instructions, but I don't see the fields in SalesForce. Is it because I need to set Security? How do I do that?
    – user3515
    Commented Sep 11, 2013 at 16:49
  • You will need to set the field level security for the profiles in your org and also add the field(s) to the appropriate Page Layouts. Field-Level Security Overview
    – Mark Pond
    Commented Sep 11, 2013 at 20:50
  • @Mrk Pond . The process creates the field on other objects but it doesn't pull the value after converting from lead.
    – Sindoora
    Commented Oct 22, 2014 at 12:43
  • @Sindoora you should ask this in a new question rather than a comment here. You can link to this question for reference if it assists in the context of your issue with the Lead conversion process.
    – Mark Pond
    Commented Oct 22, 2014 at 16:54
1

You can use Eclipse to move the custom field configuration from one Lead to Contacts. Just open the Lead object in eclipse and view them as XML. Now copy the XML data to Contacts field folder and save it.

Fetch Object in Force.com IDE. Now Open Lead Object by Open With | Text Editor > you will see a XML file search for xml tag <field></field>. This is the configuration for fields in object.

Now see the in it to check which field to copy then copy the entire <field> tag.

Paste this tag to contact.object file in your eclipse project near to other field tags.

Few things to remember:

  • if you are copying a standard field then append __c in of details you pasted.

  • Standard field don't have tag. Append it between <field></field> as <label>field label</label>

Ex: copied LeadSource field to contacts:

 <fields>
        <fullName>LeadSource__c</fullName>
        <externalId>false</externalId>
        <label>Lead Source custom</label>
        <picklist>
            <picklistValues>
                <fullName>Web</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Phone Inquiry</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Partner Referral</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Purchased List</fullName>
                <default>false</default>
            </picklistValues>
            <picklistValues>
                <fullName>Other</fullName>
                <default>false</default>
            </picklistValues>
            <sorted>false</sorted>
        </picklist>
        <trackHistory>false</trackHistory>
        <type>Picklist</type>
    </fields>

Basically this a hack which can be done using Eclipse Force.com IDE only. Well there is a idea has been posted about copying field across objects here

2
  • 1
    You can do this with the Metadata Toolkit, too. The Force.com IDE isn't the only way.
    – sfdcfox
    Commented Sep 10, 2013 at 16:52
  • Yes I know, I don't think here would be answer from that approach as it happen by code. I prefer simple. Thanks for adding this information @sfdcfox
    – Ashwani
    Commented Sep 10, 2013 at 16:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .