What is Metadata ?
First you need to understand data. What is data in context with Salesforce. Data is anything which is stored in a database like records related to Contacts, Accounts, Leads Opportunity etc.
Metadata : Metadata can be defined as the set of data about another data. i.e., Configuration/Code/Logic of the underlying structure which is used to store the data (Records). Another definition is you can say the database structure in which you will be saving the data. Metadata Api for Salesforce can do several things programmatically.
Some of the tasks are mentioned below:
You can read, create, update, delete following components in a Salesforce organization.
- Custom Objects/Fields.
- Visualforce pages.
- Page Layouts.
- Validation rules.
- Apex.
- Workflows.
- Approval processes.
- Profiles.
- Reports etc.
- Security.
You can configure a Salesforce organization just by running a piece of code. It means that you can create Objects,Fields,Validation,Workflows, Profiles, Reports for a particular client organization just by running the piece of code so that you need not do all the customisation settings manually which will consume time if you have to do that several times for different clients for the same configuration settings. You can also take the backup of your organization customisation settings just by fetching the metadata WSDL from your Salesforce org. For this You need to click setup>type API-Click on API >Click Generate metadata WSDL and download the xml file.
There are two types of Metadata Api calls:
- Synchronous - This will give the result immediately as soon as you call a method.
- Asynchronous - This will not give result immediately, it will take time.
Asynchronous : There are four types of methods which we can use:
- Create();
- Update();
- Upsert();
- Delete();
We will discuss only for synchronous method.