SlideShare a Scribd company logo
Presentation Title Date 
Best practices in using Salesforce 
Meta Data API 
Naveen Gabrani 
CEO Astrea IT Services 
ngabrani At astreait.com 
@ngabrani 
Copyright Salesforce 2014. Legal Terms and more here. 
Sanchit Dua 
Senior Software Developer Astrea IT Services 
@Sanchit1 
Naveen Gabrani 
CEO Astrea IT Services 
ngabrani At astreait.com
Presentation Title Date 
Copyright Salesforce 2014. Legal Terms and more here. 
Sanchit Dua 
Senior Software Developer Astrea IT Services 
Agenda 
1. What is Metadata 
2. What is Metadata API 
3. How can I access it? 
4. Two type of Metadata operations 
5. Common applications of the Metadata API 
6. Development Scenarios and correct implementation 
7. Best Practices and common issues
Presentation Title Date 
What is Metadata 
 Data: Some thing that is stored in database (accounts) 
 Metadata: Configuration/Code describes how the application looks 
 Shapes the functionality of your specific applications 
 Controls logic and presentation 
What is Metadata API 
 Programmable interface to access Salesforce Metadata 
 Allows you to review/update Metadata components 
 Supported from all modern languages like .Net, Java, PHP 
 Allows you to get/update XML version of an Org 
 SOAP based 
 Supports both Synchronous and Asynchronous invocation 
 Synchronous support added in Summer ’13 
Copyright Salesforce 2014. Legal Terms and more here.
Presentation Title Date 
Applications of Metadata API 
 Standard Salesforce tools written using Metadata API 
 Eclipse IDE 
 ANT Migration tool 
 Data loader 
 Standard configuration on all your customer instances 
 Java screens to create Salesforce objects, fields, validation rules etc 
 Regular backup of configuration 
Metadata Components 
Metadata components 
 Object and Field definitions 
 Visualforce pages 
 Page Layouts 
 Validation rules 
 Apex 
 Workflows 
 Profiles 
 Reports 
Copyright Salesforce 2014. Legal Terms and more here.
Presentation Title Date 
Metadata API 
CRUD Operations File Based (Declarative) 
Copyright Salesforce 2014. Legal Terms and more here. 
Metadata 
Use this to create/update 
Metadata elements like Objects 
Use this for deploying 
Metadata from one Salesforce 
instance to another 
More Granular Deploy() and Retrieve() 
CRUD based web services 
 Used to create, delete, update sets of Metadata components 
 Create a field 
 Create an object 
 Create a page layout 
 Setting Field Level Security 
 Synchronous Methods as of v-31 (Summer ’14) 
 createMetadata() 
 deleteMetadata() 
 udpateMetadata() 
 upsertMetadata()
Presentation Title Date 
create() flow 
User SFDC 
Copyright Salesforce 2014. Legal Terms and more here. 
AsyncResult object generated. 
Includes ID 
create(new CustomObject(“MyObject”)) 
Return Async Result 
CheckStatus(ID) = done? 
Return Deploy Messages 
CustomObject co = new CustomObject(); 
co.setFullName(uniqueName); 
co.setDeploymentStatus(DeploymentStatus.Deployed 
); 
co.setDescription("Created by Sanchit"); 
co.setEnableActivities(true); 
co.setLabel(label); 
co.setPluralLabel(label + "s"); 
co.setSharingModel(SharingModel.ReadWrite); 
AsyncResult[] results = 
metadataConnection.create(new Metadata[] { co }); 
User 
SFDC CustomObject is <xsd: extension 
base=“tns:Metadata”> 
File based Metadata call 
 File-based Metadata calls 
 Retrieve and deploy XML representations of Metadata 
 Can be used to deploy Metadata from one instance to another 
 Requires package.xml 
 Specifies type of component 
 Specifies names of component
Presentation Title Date 
A typical custom object example 
{File Name: CustomObject/MyObject__c} 
<?xml version="1.0" encoding="UTF-8"?> 
<CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> 
<deploymentStatus>Deployed</deploymentStatus> 
<fields> 
<fullName>Due_Date__c</fullName> 
<defaultValue>TODAY() + 3</defaultValue> 
<label>Due Date</label> 
<type>Date</type> 
</fields> 
<sharingModel>ReadWrite</sharingModel> 
<recordTypes> 
<fullName>Classification</fullName> 
<active>true</active> 
<description>Classification Records</description> 
<label>Classification</label> 
</recordTypes> 
<recordTypes> 
<fullName>Client_Code</fullName> 
<active>true</active> 
<description>Client Code Records</description> 
<label>Client Code</label> 
</recordTypes> 
</CustomObject> 
Create 
your 
Database 
Tables 
Create 
your 
Database 
Fields 
Copyright Salesforce 2014. Legal Terms and more here. 
Define 
Schema 
attributes 
Metadata API and SOAP API 
Metadata 
Data 
Metadata 
Data 
Metadata 
API 
Web 
Services 
API 
Metadata 
API 
Web 
Services 
API
Presentation Title Date 
Setting up infrastructure 
1. Download the latest WSC – Web Service Connector 
2. From Setup->API 
Enterprise WSDL 
Metadata WSDL 
3. Generate the Jar files from WSDL 
4. Set the classpath of the Application. 
Establishing Connection 
1. Use ConnectorConfig class to set end point to 
https://login.salesforce.com/services/Soap/c/31.0 
2. Use EnterpriseConnection to specify user name and password to login 
3. Initialize Metadata component – e.g CustomObject, CustomField etc. 
4. Pass the Metadata component to create() / update() / delete() call. 
Copyright Salesforce 2014. Legal Terms and more here.
Presentation Title Date 
Best Practices and common issues 
Development Scenarios 
 Setting the Page Layout 
 Editing the Profile 
 Creating Record Types 
Enforcing rules at runtime involves recompiling of code (with associated 
possibility of compile time errors). 
Copyright Salesforce 2014. Legal Terms and more here.
Presentation Title Date 
Profile Edits 
Configuring a Profile: 
 Open a profile 
 Edit configurations 
NOTE 
 It’s a complex task to achieve via coding without knowing listMetadata() or Workbench. 
 Default Result of listMetadata() as: 
SolutionManager 
Customer Portal Manager 
Standard StandardAul 
Standard 
Chatter Free User 
Chatter External User 
Copyright Salesforce 2014. Legal Terms and more here. 
Admin 
Force%2Ecom - Free User 
MarketingProfile 
Custom%3A Marketing Profile 
HighVolumePortal 
Record Types Creation 
Generally available steps 
 Add a record Type 
 Assign it to layouts and profiles 
 Clicking new on the object view 
NOTE 
 This case is very easily done on declarative platform 
 Doing this via Metadata API is relatively complex
Presentation Title Date 
Insufficient Access On Cross Reference Entity 
 An exception 
 Using Create, Update and Delete 
 Occurs using record type id 
Copyright Salesforce 2014. Legal Terms and more here. 
Demo
Presentation Title Date 
A quirk using Ant Migration Tool 
 Using destructiveChanges.xml 
 To delete a field of type picklist we can’t delete the values instead we delete the 
whole field. 
 This is the limitation of Metadata API. 
Tooling API 
 The tooling API is designed for developing user interface tools to interact with 
the development artifacts in orgs. 
 It can be accessed via SOAP and REST. 
 Developer Console is largely built on the tooling API 
 Best used in conjunction with the Metadata API as a junction. 
Copyright Salesforce 2014. Legal Terms and more here.
Presentation Title Date 
Recap 
 Metadata API gives you flexibility to manipulate Salesforce instance 
from outside the platform 
 Two types of Metadata API 
 CRUD based 
 Declarative 
 Application Business process code needs to mimic the user interface 
flow 
 Record Type Creations 
 Profile Edits 
 More important than ever that you define and enforce the boundaries 
 You should respect the intent of platform configurations and not 
surface data in ways that is not permitted. 
Resources 
 Metadata API Developer’s Guide 
 http://www.salesforce.com/us/developer/docs/api_meta 
 https://developer.salesforce.com/en/events/webinars/metadata-api 
 salesforce.stackexchange.com 
 https://github.com/sanchitdua/md_java_asynchronous 
 https://github.com/sanchitdua/md_java_synchronous 
Copyright Salesforce 2014. Legal Terms and more here.
Presentation Title Date 
Copyright Salesforce 2014. Legal Terms and more here. 
Q&A

More Related Content

Viewers also liked (6)

PDF
Salesforce Admin Habits & Stats
Cloudingo
 
PPTX
Continuous Integration with Bamboo for Salesforce
Klea Kolaric
 
PDF
Salesforce Performance hacks - Client Side
Paris Salesforce Developer Group
 
PDF
Salesforce API Series: Release Management with the Metadata API webinar
Salesforce Developers
 
PPTX
Dreamforce14 Multi Org Collaboration Architecture
Richard Clark
 
PDF
Best practice strategies to clean up and maintain your database with Hether G...
Blackbaud Pacific
 
Salesforce Admin Habits & Stats
Cloudingo
 
Continuous Integration with Bamboo for Salesforce
Klea Kolaric
 
Salesforce Performance hacks - Client Side
Paris Salesforce Developer Group
 
Salesforce API Series: Release Management with the Metadata API webinar
Salesforce Developers
 
Dreamforce14 Multi Org Collaboration Architecture
Richard Clark
 
Best practice strategies to clean up and maintain your database with Hether G...
Blackbaud Pacific
 

Similar to Best practices in using Salesforce Metadata API (20)

PDF
Best practices in using Salesforce Metadata API
Sanchit Dua
 
PPTX
Custom Metadata Data Types
Samuel Moyson
 
PPTX
Play with force.com metadata
Rakesh Kumar Kedia
 
PDF
4 Ways to Fetch Metadata in Salesforce | Salesforce Metadata
AutoRABIT
 
PPTX
February 2020 Salesforce API Review
Lydon Bergin
 
PPT
Custom Metadata Records Deployment From Apex Code
Bohdan Dovhań
 
PDF
Beyond Custom Metadata Types
Salesforce Developers
 
PPTX
Deep Dive into Salesforce Integrations: Mapping Engines
CRMScienceKirk
 
PDF
ISV Monthly Tech Enablement (May 18, 2017)
Salesforce Partners
 
PDF
Use Custom Metadata Types for Easy ALM & Compliance for Your Custom Apps
Salesforce Developers
 
PPTX
The tooling Api demystified, It is not only for developers, Doria Hamelryk & ...
CzechDreamin
 
PPTX
Sales force
Raj Kumar Ranabhat
 
PPTX
Singapore Admin Group - 5 Free Admin Tools to Make Your Life Easier
Joey Chan
 
PDF
Handling of Large Data by Salesforce
Thinqloud
 
PDF
Elevate london dec 2014.pptx
Peter Chittum
 
PDF
Blazing new trails with salesforce data nov 16, 2021
Safe Software
 
PPTX
Integrating with salesforce
Mark Adcock
 
PPTX
Salesforce Application Development
Nishtha Gupta
 
PPTX
Summer '16 Realease notes
aggopal1011
 
PPTX
Salesforce Integration Patterns
usolutions
 
Best practices in using Salesforce Metadata API
Sanchit Dua
 
Custom Metadata Data Types
Samuel Moyson
 
Play with force.com metadata
Rakesh Kumar Kedia
 
4 Ways to Fetch Metadata in Salesforce | Salesforce Metadata
AutoRABIT
 
February 2020 Salesforce API Review
Lydon Bergin
 
Custom Metadata Records Deployment From Apex Code
Bohdan Dovhań
 
Beyond Custom Metadata Types
Salesforce Developers
 
Deep Dive into Salesforce Integrations: Mapping Engines
CRMScienceKirk
 
ISV Monthly Tech Enablement (May 18, 2017)
Salesforce Partners
 
Use Custom Metadata Types for Easy ALM & Compliance for Your Custom Apps
Salesforce Developers
 
The tooling Api demystified, It is not only for developers, Doria Hamelryk & ...
CzechDreamin
 
Sales force
Raj Kumar Ranabhat
 
Singapore Admin Group - 5 Free Admin Tools to Make Your Life Easier
Joey Chan
 
Handling of Large Data by Salesforce
Thinqloud
 
Elevate london dec 2014.pptx
Peter Chittum
 
Blazing new trails with salesforce data nov 16, 2021
Safe Software
 
Integrating with salesforce
Mark Adcock
 
Salesforce Application Development
Nishtha Gupta
 
Summer '16 Realease notes
aggopal1011
 
Salesforce Integration Patterns
usolutions
 
Ad

Recently uploaded (20)

PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
PDF
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
PDF
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
PDF
July Patch Tuesday
Ivanti
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
Biography of Daniel Podor.pdf
Daniel Podor
 
PPTX
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
PDF
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
PDF
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
PDF
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
HCIP-Data Center Facility Deployment V2.0 Training Material (Without Remarks ...
mcastillo49
 
From Code to Challenge: Crafting Skill-Based Games That Engage and Reward
aiyshauae
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
Presentation - Vibe Coding The Future of Tech
yanuarsinggih1
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Newgen 2022-Forrester Newgen TEI_13 05 2022-The-Total-Economic-Impact-Newgen-...
darshakparmar
 
The Rise of AI and IoT in Mobile App Tech.pdf
IMG Global Infotech
 
July Patch Tuesday
Ivanti
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
Biography of Daniel Podor.pdf
Daniel Podor
 
WooCommerce Workshop: Bring Your Laptop
Laura Hartwig
 
Exolore The Essential AI Tools in 2025.pdf
Srinivasan M
 
Jak MŚP w Europie Środkowo-Wschodniej odnajdują się w świecie AI
dominikamizerska1
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
Bitcoin for Millennials podcast with Bram, Power Laws of Bitcoin
Stephen Perrenod
 
Ad

Best practices in using Salesforce Metadata API

  • 1. Presentation Title Date Best practices in using Salesforce Meta Data API Naveen Gabrani CEO Astrea IT Services ngabrani At astreait.com @ngabrani Copyright Salesforce 2014. Legal Terms and more here. Sanchit Dua Senior Software Developer Astrea IT Services @Sanchit1 Naveen Gabrani CEO Astrea IT Services ngabrani At astreait.com
  • 2. Presentation Title Date Copyright Salesforce 2014. Legal Terms and more here. Sanchit Dua Senior Software Developer Astrea IT Services Agenda 1. What is Metadata 2. What is Metadata API 3. How can I access it? 4. Two type of Metadata operations 5. Common applications of the Metadata API 6. Development Scenarios and correct implementation 7. Best Practices and common issues
  • 3. Presentation Title Date What is Metadata  Data: Some thing that is stored in database (accounts)  Metadata: Configuration/Code describes how the application looks  Shapes the functionality of your specific applications  Controls logic and presentation What is Metadata API  Programmable interface to access Salesforce Metadata  Allows you to review/update Metadata components  Supported from all modern languages like .Net, Java, PHP  Allows you to get/update XML version of an Org  SOAP based  Supports both Synchronous and Asynchronous invocation  Synchronous support added in Summer ’13 Copyright Salesforce 2014. Legal Terms and more here.
  • 4. Presentation Title Date Applications of Metadata API  Standard Salesforce tools written using Metadata API  Eclipse IDE  ANT Migration tool  Data loader  Standard configuration on all your customer instances  Java screens to create Salesforce objects, fields, validation rules etc  Regular backup of configuration Metadata Components Metadata components  Object and Field definitions  Visualforce pages  Page Layouts  Validation rules  Apex  Workflows  Profiles  Reports Copyright Salesforce 2014. Legal Terms and more here.
  • 5. Presentation Title Date Metadata API CRUD Operations File Based (Declarative) Copyright Salesforce 2014. Legal Terms and more here. Metadata Use this to create/update Metadata elements like Objects Use this for deploying Metadata from one Salesforce instance to another More Granular Deploy() and Retrieve() CRUD based web services  Used to create, delete, update sets of Metadata components  Create a field  Create an object  Create a page layout  Setting Field Level Security  Synchronous Methods as of v-31 (Summer ’14)  createMetadata()  deleteMetadata()  udpateMetadata()  upsertMetadata()
  • 6. Presentation Title Date create() flow User SFDC Copyright Salesforce 2014. Legal Terms and more here. AsyncResult object generated. Includes ID create(new CustomObject(“MyObject”)) Return Async Result CheckStatus(ID) = done? Return Deploy Messages CustomObject co = new CustomObject(); co.setFullName(uniqueName); co.setDeploymentStatus(DeploymentStatus.Deployed ); co.setDescription("Created by Sanchit"); co.setEnableActivities(true); co.setLabel(label); co.setPluralLabel(label + "s"); co.setSharingModel(SharingModel.ReadWrite); AsyncResult[] results = metadataConnection.create(new Metadata[] { co }); User SFDC CustomObject is <xsd: extension base=“tns:Metadata”> File based Metadata call  File-based Metadata calls  Retrieve and deploy XML representations of Metadata  Can be used to deploy Metadata from one instance to another  Requires package.xml  Specifies type of component  Specifies names of component
  • 7. Presentation Title Date A typical custom object example {File Name: CustomObject/MyObject__c} <?xml version="1.0" encoding="UTF-8"?> <CustomObject xmlns="http://soap.sforce.com/2006/04/metadata"> <deploymentStatus>Deployed</deploymentStatus> <fields> <fullName>Due_Date__c</fullName> <defaultValue>TODAY() + 3</defaultValue> <label>Due Date</label> <type>Date</type> </fields> <sharingModel>ReadWrite</sharingModel> <recordTypes> <fullName>Classification</fullName> <active>true</active> <description>Classification Records</description> <label>Classification</label> </recordTypes> <recordTypes> <fullName>Client_Code</fullName> <active>true</active> <description>Client Code Records</description> <label>Client Code</label> </recordTypes> </CustomObject> Create your Database Tables Create your Database Fields Copyright Salesforce 2014. Legal Terms and more here. Define Schema attributes Metadata API and SOAP API Metadata Data Metadata Data Metadata API Web Services API Metadata API Web Services API
  • 8. Presentation Title Date Setting up infrastructure 1. Download the latest WSC – Web Service Connector 2. From Setup->API Enterprise WSDL Metadata WSDL 3. Generate the Jar files from WSDL 4. Set the classpath of the Application. Establishing Connection 1. Use ConnectorConfig class to set end point to https://login.salesforce.com/services/Soap/c/31.0 2. Use EnterpriseConnection to specify user name and password to login 3. Initialize Metadata component – e.g CustomObject, CustomField etc. 4. Pass the Metadata component to create() / update() / delete() call. Copyright Salesforce 2014. Legal Terms and more here.
  • 9. Presentation Title Date Best Practices and common issues Development Scenarios  Setting the Page Layout  Editing the Profile  Creating Record Types Enforcing rules at runtime involves recompiling of code (with associated possibility of compile time errors). Copyright Salesforce 2014. Legal Terms and more here.
  • 10. Presentation Title Date Profile Edits Configuring a Profile:  Open a profile  Edit configurations NOTE  It’s a complex task to achieve via coding without knowing listMetadata() or Workbench.  Default Result of listMetadata() as: SolutionManager Customer Portal Manager Standard StandardAul Standard Chatter Free User Chatter External User Copyright Salesforce 2014. Legal Terms and more here. Admin Force%2Ecom - Free User MarketingProfile Custom%3A Marketing Profile HighVolumePortal Record Types Creation Generally available steps  Add a record Type  Assign it to layouts and profiles  Clicking new on the object view NOTE  This case is very easily done on declarative platform  Doing this via Metadata API is relatively complex
  • 11. Presentation Title Date Insufficient Access On Cross Reference Entity  An exception  Using Create, Update and Delete  Occurs using record type id Copyright Salesforce 2014. Legal Terms and more here. Demo
  • 12. Presentation Title Date A quirk using Ant Migration Tool  Using destructiveChanges.xml  To delete a field of type picklist we can’t delete the values instead we delete the whole field.  This is the limitation of Metadata API. Tooling API  The tooling API is designed for developing user interface tools to interact with the development artifacts in orgs.  It can be accessed via SOAP and REST.  Developer Console is largely built on the tooling API  Best used in conjunction with the Metadata API as a junction. Copyright Salesforce 2014. Legal Terms and more here.
  • 13. Presentation Title Date Recap  Metadata API gives you flexibility to manipulate Salesforce instance from outside the platform  Two types of Metadata API  CRUD based  Declarative  Application Business process code needs to mimic the user interface flow  Record Type Creations  Profile Edits  More important than ever that you define and enforce the boundaries  You should respect the intent of platform configurations and not surface data in ways that is not permitted. Resources  Metadata API Developer’s Guide  http://www.salesforce.com/us/developer/docs/api_meta  https://developer.salesforce.com/en/events/webinars/metadata-api  salesforce.stackexchange.com  https://github.com/sanchitdua/md_java_asynchronous  https://github.com/sanchitdua/md_java_synchronous Copyright Salesforce 2014. Legal Terms and more here.
  • 14. Presentation Title Date Copyright Salesforce 2014. Legal Terms and more here. Q&A