Activity Forums Salesforce® Discussions How to create custom objects/setting using Apache Ant in Salesforce?

  • Ratnakar

    Member
    March 14, 2018 at 7:28 am

    Hi Kapil,

    we cannot create objects using Apache ant but we can migrate objects from one salesforce org to another
    Following are the steps to migrate objects from one org to another:
    1.In the build.properties specify the username and password of the source and destination org.
    2.In the package.xml specify the name of object you want to retrieve.
    3.your build.properties look like this
    # build.properties
    #

    # Specify the login credentials for the desired Salesforce organization
    [email protected]
    sf.password=xxxxxxxxxxxxxxxxx

    [email protected]
    sf1.password=xxxxxxxxxxxxxxxxx
    #sf.sessionId = <Insert your Salesforce session id here. Use this or username/password above. Cannot use both>
    #sf.pkgName = <Insert comma separated package names to be retrieved>
    #sf.zipFile = <Insert path of the zipfile to be retrieved>
    #sf.metadataType = <Insert metadata type name for which listMetadata or bulkRetrieve operations are to be performed>

    # Use 'https://login.salesforce.com' for production or developer edition (the default if not specified).
    # Use 'https://test.salesforce.com for sandbox.
    sf.serverurl = https://login.salesforce.com
    sf1.serverurl = https://login.salesforce.com

    sf.maxPoll = 120
    sf1.maxPoll = 120
    # If your network requires an HTTP proxy, see http://ant.apache.org/manual/proxy.html for configuration.
    #

    4.your package.xml look like this

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
    <members>specify the name of custom object</members>
    <name>CustomObject</name>
    </types>
    <version>40.0</version>
    </Package>
    5.command to retrieve object
    ant retrieveUnpackaged

    6.command to deploy object
    ant deployUnpackaged

  • Parul

    Member
    September 18, 2018 at 7:11 pm

    here is code snippet

    <?xml version="1.0" encoding="UTF-8"?>
    <Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
    <members>*</members>
    <name>CustomMetadata</name>
    </types>
    <version>40.0</version>
    </Package>

    Custom Object:

    <Package xmlns="http://soap.sforce.com/2006/04/metadata">
    <types>
    <members>ABC__mdt</members>
    <name>CustomObject</name>
    </types>
    <version>40.0</version>
    </Package>

     

    Thanks

  • shariq

    Member
    September 19, 2018 at 9:24 pm

    Hi,

    Apache Ant is a Java library and command-line tool. Ant was originally used for building Java applications, but Salesforce.com supplies extra libraries to enable Ant to move metadata between a local directory and a Salesforce org. The Ant-Salesforce Libraries are known as the Force.com Migration Tool. There are many methods for migrating metadata (change sets, for example).

    <?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&gt;">
    <fullName>test</fullName>
    <types>
    <members>testss__c</members>
    <name>CustomObject</name>
    </types>
    <types>
    <members>testss__c.fields__c</members>
    <name>CustomField</name>
    </types>
    <types>
    <members>testss__c.fields2</members>
    <name>CustomField</name>
    </types>
    <version>20.0</version>
    </Package>

    Hope this helps.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos