Salesforce Metadata API
Aug23

Salesforce Metadata API

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. Synchronous : There are five types of methods which we can use: (i) createMetadata(); saveResult[] = metadataConnection.createMetadata(Metadata[] metadata); (ii) readMetadata(); readResult = metadataConnection.readMetadata(string metadataType, string[] fullNames); (iii)updateMetadata(); saveResult[] = metadataConnection.updateMetadata(Metadata[] metadata); (iv)upsertMetadata(); spsertResult[] = metadataConnection.upsertMetadata(Metadata[] metadata); (v)deleteMetadata(); seleteResult[] = metadataConnection.delete(string metadataType, string[] fullNames); All these classes saveResult, readResult, upsertResult, deleteResult comes from a main class that is MetadataService.cls in which all the relevant methods are present to function Read, Create, Update, Upsert or Delete properly. Now I will demonstrate how to create Custom components. You can use following methods to create components: (A) To Create a Custom Object: You need to add this code to your class which you are using and call this method via class name to create the object. Note: MetadataService is also a class which have several methods and used in these methods. Create a Custom Object: public static void createObject() {  ...

Read More
Salesforce Code Move Strategy
Aug09

Salesforce Code Move Strategy

Why sometimes a few lines of code changes take several days of deployment. Find the answers and Code Move Strategy:- Recently In one of my project I faced the following situation: We did a code change in trigger. Changed a string value from “Demo” to “Trial”. The code change hardy took 1 minutes. Client was aware of the changes and  time it will take so we estimated the work as 2 hour including code changes, analysis of its impact and deployment. When the developer finished deploying the code changes it took him 2 days (16+ Man-hours). Yes it is a surprise. Now let me list out the problems he faced.   Code coverage of the existing trigger was 12% (Our Company Best Practice is 85%) Code coverage of overall production org was less than 75%. Yes this is hard to believe but this do happen when we push things in production without code coverage. Existing test classes were failing in production. Trigger in production was different than in Sandbox. Yes this is also possible when we have multiple sandboxes and people do code overrides as they are competing against each others. Deployment had a narrow slot of 2 hours during which end client were not working. Batch Jobs working on the same object were preventing the Trigger to deploy. We gave our best as a team and came up with the following strategy which changed our entire company’s estimation and requirement analysis process. Code Move Strategy: Step 1: Check the existing production code coverage by “Run All Test”. Step 2: Lookout for test class failures if any. Step 3: List out the Batch jobs running in production. Step 4: Compare the code between production and sandbox before working on it. If any differences found report it to your end Client/Manager. Step 5: Make sure if you are deploying an apex code its code coverage should be above 85%. Step 6: Use Changeset for small size deployment with less components. Keep the changeset names in a well defined order. Step 7: Use Eclipse or Ant Migration tool for deployment with many components.If you have the privilege of Full copy sandbox use it for trial deployment and go live. Full copy sandbox gives you an advantage of less risk more effort based deployment process. Step 8: Deactivate the necessary batch jobs and validation rules before deployment. Step 9: Make sure the deployment is in the right time slot when end users are not working or keep the team informed for any surprises that may come while deployment or after that. Step 10: Validate and Deploy. Reactivate the Jobs, VRs etc. Step...

Read More
Learning Salesforce in India
Aug01

Learning Salesforce in India

Its a casual day and some newbie in Salesforce asked me “Is Learning Salesforce in India worth”. Mine and everyone’s first answer would be “Do you have the budget to either fly to a western country or pay USD 2000 fees of Salesforce Training online?” Well that is not the cross question what I replied back with. I thought of giving an elaborative answer and wrote this blog. Here are few points I believe “Why Learning Salesforce in India is worth” Young India: We have 1000s of Salesforce enthusiast every year joining in the Salesforce community and 100s of Salesforce Experts in India. With Salesforce everyone is trying to show off and learn as much as possible. This thinking process of an Indian helps other to jump into the competition. With competition one either fails and learns or succeeded and teach others. Salesforce Community: I can see at least 40+ Salesforce Users and Developers group in India and several new groups coming up every day. In past 2 years there is an almost 300% rise in number of registered groups in India. These communities can definitely help you with learning Salesforce and several Recruiters target for bright minds in these groups. Salesforce in India: Salesforce is taking interest. With new announcements from Salesforce investing in hiring Developers and Experts in India it gives a better opportunity for every newbie/fresher. Thus a reason to Learn Salesforce in India is prominent. I believe in No Pain No Gain. To learn anything you should not expect spoonfeeding instead you should be brave and intelligent enough to go out and search for knowledge. The entire social media, youtube, blogs, trail heads, Quora is filled up with information and learning material. www.ajaydubedi.com Startups Hire Freshers: Several Companies startups like mine(www.cloudanalogy.com) are trying to hire freshers and train them in Salesforce. These companies give awesome opportunity to newbies and experienced upto a certain level to get trained and be productive in Salesforce. Salesforce Consultants and Admins: People who are not from a coding background but good at other areas like communication, consulting Testing, Problem solving and also be part of salesforce. Majority of Salesforce business runs around Admins and Consultants Read my blogs regularly to know about the 7th most important reason.www.ajaydubedi.com   I would request everyone reading this blog to share their experience with different Training institutes in India. Name of Institute, Fees, Time duration and Quality of Training. Submit this detail in the comments and win the following Salesforce development...

Read More