function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
arasuarasu 

How can I deploy custom fields in Standard objects from Sandbox to Production?

Hi,

I have added about 100 custom fields in the standard Account object in sandbox . How can we deploy these 100 fields to Production? I tried from eclipse IDE(force.com IDE) but did not find the Account object XML to deploy. Currently the only way I can think of is to manually create these 100 custom fields in production.
 
Appreciate all help in this.
 
Regards,
Ambili
Best Answer chosen by Admin (Salesforce Developers) 
JonPJonP
Ambili,

You can include standard objects in your Force.com IDE projects in either of two ways:

1. Add the custom fields on a standard object to a package.  This will create a .object file for the standard obejct, containing only the custom fields on that standard object that are in the package, e.g. src/MyPackageName/objects/Account.object

2. Add the name of the fields or the object to src/unpackaged/package.xml.  Warning: Be cautious not to inadvertantly damage your production Field-Level Security settings.  See note below.

- Option A. Add a CustomField type section:

<types>
  <members>Account.MyCustomFieldName1__c</members>
  <members>Account.MyCustomFieldName2__c</members>
  <name>CustomField</name>
</types>

- Option B. Add the standard object name to the CustomObject type section:

<types>
  <members>*</members>
  <members>Account</members>
  <name>CustomObject</name>
</types>

NOTE: Adding a standard object to the CustomObject section will cause your .profile files to contain Field-Level Security information for all standard and custom fields on the standard object, the next time you refresh your profiles folder from the server.  If you deploy such a .profile file to your production org, you will overwrite these Field-Level Security settings.

This should let you do what you need, just be careful about FLS!

Jon

All Answers

JonPJonP
Ambili,

You can include standard objects in your Force.com IDE projects in either of two ways:

1. Add the custom fields on a standard object to a package.  This will create a .object file for the standard obejct, containing only the custom fields on that standard object that are in the package, e.g. src/MyPackageName/objects/Account.object

2. Add the name of the fields or the object to src/unpackaged/package.xml.  Warning: Be cautious not to inadvertantly damage your production Field-Level Security settings.  See note below.

- Option A. Add a CustomField type section:

<types>
  <members>Account.MyCustomFieldName1__c</members>
  <members>Account.MyCustomFieldName2__c</members>
  <name>CustomField</name>
</types>

- Option B. Add the standard object name to the CustomObject type section:

<types>
  <members>*</members>
  <members>Account</members>
  <name>CustomObject</name>
</types>

NOTE: Adding a standard object to the CustomObject section will cause your .profile files to contain Field-Level Security information for all standard and custom fields on the standard object, the next time you refresh your profiles folder from the server.  If you deploy such a .profile file to your production org, you will overwrite these Field-Level Security settings.

This should let you do what you need, just be careful about FLS!

Jon
This was selected as the best answer
MCunninghamMCunningham
Im having trouble setting up my IDE as you describe (stumbling in the dark more like!)

if its not being cheeky; is there any chance you could forward a screen grab showing how your amended package.xml looks  once you have inserted a few custom fields in standard objects  - Im trying to understand how mass deploy them in one go.

Many thanks

my email is michaelfcunningham@hotmail.com

JonPJonP
Here's a complete package.xml for downloading an Account.object file containing two custom fields "MyCustomField1" and "MyCustomField2" and the Profile permissions on these objects:

Code:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
       <members>Account.MyCustomField1__c</members>
       <members>Account.MyCustomField2__c</members>
       <name>CustomField</name>
    </types>
    <types>
<members>*</members>
<name>Profile</name>
</types>
<version>13.0</version> </Package>

If you just want to deploy the custom fields but not the Profile security settings (you can configure that later in your production organization), omit the <types>...</types> section for Profile when you retrieve.