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
dmchengdmcheng 

Using ant to deploy custom objects

Hello.  I have a metadata .object file and I'm trying to use ant to create the custom object in my sandbox.  If I limit the package.xml file to a single field, then it works, but if I try to create all the fields, I get errors "not in package.xml" even though I do have the fields there.

 

I've searched the documentation but there is no good example on how to deploy a complete custom object.  Any ideas as to where I'm going wrong?

 

BTW - this is a Custom Settings object.

 

Here's a portion of my xml file:

 

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <fullName>GWpkg</fullName>
    <types>
        <members>OppRollupSettings__c</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>OppRollupSettings__c.Assume_Fiscal_Year_Starts_January__c</members>
        <name>CustomField</name>
    </types>
    <types>
        <members>OppRollupSettings__c.Enable_Opp_Rollup_Triggers__c</members>
        <name>CustomField</name>
    </types>
    <version>20.0</version>
</Package>

 

 

 

Here's my build.properties file:

 

"antlib:com.salesforce">

    <property file="build.properties"/>
    <property environment="env"/>

    <!-- Test out deploy and retrieve verbs for package 'GWpkg' -->
    <target name="deploy">
      <!-- Upload the contents of the "GWpkg" package -->
      <sf:deploy username="${sf.username}" password="${sf.password}" serverurl="${sf.serverurl}" deployRoot="GWpkg"/>
    </target>
</project>

 

 

 

 

Cory CowgillCory Cowgill

Take a look at the Developer Guide ANT Example. http://wiki.developerforce.com/index.php/Developer_Guide_Intro

 

There are some packages there which upload Custom Objects. Here is the direct link to the source:

 

http://www.apexdevnet.com/media/ForcedotcomBookLibrary/DevGuide20081003.zip

Cory CowgillCory Cowgill

You mention this is a Custom Setting also. Have you tried a regular Custom Object? Custom Settings are a little bit finicky, you can't create them in the IDE for example.

Jaap ScheperJaap Scheper
Merge the fields in one root <types> attribute
<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="<a href="http://soap.sforce.com/2006/04/metadata" target="_blank" rel="nofollow">http://soap.sforce.com/2006/04/metadata</a>">
    <fullName>GWpkg</fullName>
    <types>
        <members>OppRollupSettings__c</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>OppRollupSettings__c.Enable_Opp_Rollup_Triggers__c</members>
        <members>OppRollupSettings__c.Assume_Fiscal_Year_Starts_January__c</members>
        <name>CustomField</name>
    </types>
    <version>20.0</version>
</Package>

 
Malika Pathak 9Malika Pathak 9

Hi dmcheng,
if you want to deploy all custom fields in ORG the use this code 

<?xml version="1.0" encoding="UTF-8"?>
<Package xmlns="<a href="http://soap.sforce.com/2006/04/metadata" target="_blank" rel="nofollow">http://soap.sforce.com/2006/04/metadata</a>">
    <fullName>GWpkg</fullName>
    <types>
        <members>*</members>
        <name>CustomObject</name>
    </types>
    <types>
        <members>OppRollupSettings__c.Enable_Opp_Rollup_Triggers__c</members>
        <members>OppRollupSettings__c.Assume_Fiscal_Year_Starts_January__c</members>
        <name>CustomField</name>
    </types>
    <version>20.0</version>
</Package>


if you want to deploy some custom fields in ORG the use this code

 

<Package xmlns="<a href="http://soap.sforce.com/2006/04/metadata" target="_blank" rel="nofollow">http://soap.sforce.com/2006/04/metadata</a>">
    <fullName>GWpkg</fullName>
    <types>
        <members>OppRollupSettings__c</members>
        <name>CustomObject</name>
    </types>
    <types>
        
		<members>OppRollupSettings__c.FieldNameAPI1</members>
		<members>OppRollupSettings__c.FieldNameAPI2</members>
		<members>OppRollupSettings__c.FieldNameAPI3</members>
		--
		--
		--
         
        <name>CustomField</name>
    </types>
    <version>20.0</version>
</Package>

 

If you find this solution is helpful for you please mark the best answer