Activity › Forums › Salesforce® Discussions › How to create custom objects/setting using Apache Ant in Salesforce?
Tagged: Apache ANT, Apache ANT in Salesforce, Apache ANT Tools, Custom Setting, Salesforce Custom Objects, Salesforce Custom Settings
-
How to create custom objects/setting using Apache Ant in Salesforce?
Posted by kapil on March 13, 2018 at 11:54 AMHow to create custom objects/setting using Apache Ant in Salesforce?
shariq replied 7 years, 7 months ago 4 Members · 3 Replies -
3 Replies
-
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
sf.username=sourceorg@salesforce.com
sf.password=xxxxxxxxxxxxxxxxxsf1.username=destinationorg@salesforce.com
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.comsf.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 retrieveUnpackaged6.command to deploy object
ant deployUnpackaged - [adinserter block='9']
-
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
-
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>”>
<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.