Skip to main content

Salesforce Metadata API

In this post I'm going the cover basics in the Metadata API and how it can connect with a .net console application. Then after I will show you how to create a custom object and create fields by using the metadata api from the console app.
What is Salesforce Metadata API
There are many things can be done from the metadata api. 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 customization 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 customization settings just by fetching the metadata WSDL from your Salesforce org.
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.
Step 1 : Get the Metadata api url from Salesforce
In our first step we'll  need to get the metadata api url by navigating to Setup -> API -> Generate Metadata WSDL. Metadata api have SOAP and REST version. Here we are focusing on for the SOAP.
Below screen shows how to generate wsdl from Salesforce.
2
Then after copy the wsdl url.
Step 2 : Create a console application by using visual studio.
1
Here I'm using visual studio community 2017. And I'm targeting .NET framework 4.5.
Step 3 : Add the web reference in to the console application.
Right click on References in the solution explorer and click on Add Service References. Then you need to click on Advanced button and click Add Web References button. So you will end up with the below screen that you can paste the wsdl url  and click on go button which you have copied in step 1.
3.PNG
give the namespaces as "com.salesforce.metadata" and click on Add References button. Then after visual studio automatically create the related files and references in order to connect with Salesforce. But here you need to get the sessionId from Salesforce Rest api or Enterprise/Partner wsdl , because Metadata API doesn't gives the login method.

Comments

Popular posts from this blog

Exploring the Marvels of Salesforce Marketing Cloud: Unleashing the Power of Marketing Automations

Salesforce Marketing Cloud is a comprehensive marketing automation platform offered by Salesforce, a leading customer relationship management (CRM) company. It is designed to help businesses manage and optimize their marketing efforts across various channels and touchpoints. The platform enables organizations to create, execute, and analyze marketing campaigns to engage with their target audiences more effectively and drive better results. Key features and capabilities of Salesforce Marketing Cloud include: Email Marketing: Users can create and send personalized email campaigns to segmented audiences, track email performance metrics, and automate email workflows to nurture leads and build customer relationships. Journey Builder: This tool allows marketers to design and automate customer journeys across multiple channels such as email, mobile, social media, and advertising. It helps create personalized experiences based on customer behavior and interactions. Social Media Marketing: Sale...

How to connect Salesforce with .NET console application using SOAP api

This article mainly focusing on the basics about the integration with Salesforce and .NET console application via Salesforce SOAP api. So I would prefer to start it form Salesforce. :) . And I think it would be easy if I continuing with Steps so the viewers can go through the steps easily. 1st Step : Navigating to Enterprise WSDL from Salesforce. You will be able to generate WSDL in Salesforce by Navigating to Setup -> Integrations -> API.  Here you will be able to see different apis which will be generating for different purposes. In order to do this you need to log in as an system administrator or as a user who has the “Modify All Data” permission. You will be able to see below APis. Enterprise WSDL Partner WSDL Apex WSDL Metadata WSDL Tooling WSDL Generate Tooling WSDL Delegated Authentication WSDL Client Certificate Enterprise Package Version Settings Partner Package Version Settings We are focusing Enterprise WDSL in order to integrate with .NET and you want t...

How to automate testing using Selenium and C#

Hi All, today I’m going to explain about Selenium which is a open source automation tool and how to utilize it with C#. As you know automation tools save our time in terms of testing a software product. If we are doing some regression testings automation tools doing a great job in terms of saving the time. So I’m going to explain a very simple example for using Selenium from C#. We can divide selenium as two entities. One is Selenium IDE as a web browser extension. And the other one is Selenium Web Driver. So I’m going to talk about the selenium web driver which is using for web based testings from C# code. Basically Selenium Web driver will open the browser and doing the actions as we instructing in the C#code. Firstly you need to install visual studio. For my case I have installed visual studio community version which is a free version of Microsoft. Then you need to create a project by navigating to File -> New -> Project. And give a name for the project and click ok...