Salesforce Trailhead: The fun way to learn salesforce

Are you new to salesforce? Or maybe you have only worked on one area and want to learn about another?

I started on developer side of salesforce. Recently, I figured that if I know about others areas (admin, App Cloud etc) then it will make it so much easier to work on developer side. But I had the same questions as above. Where do I start?

Then I found salesforce trailhead and absolutely love it. It’s not just the content but the way it has been arranged. It took me from beginner admin to intermediate admin and other areas. After I had been through those modules, I wanted to put it all together but couldn’t figure out what I could build.

Lo and behold, trailhead has projects. These are simple enough but still allow me to combine various features that I learned.

My goal now? Go through ALL modules and projects on trailhead to get, at least, basic understanding of all salesforce features. Let the journey start……..

Apex: Find Object Type from Record ID Prefix

I get to work on objects in various orgs. It’s not easy (if at all possible) to remember entity type by just looking at Record ID Prefix. provides a Standard Record ID Prefix Decoder list. This still means you need to have this page handy to find those objects. Of course this list also cannot help with custom objects.

In my pursuit to find an answer, I came across piece of code that was answer to this exact problem. The answer uses iteration on metadata through Schema.getGlobalDescribe(). As it loops through all sObjects in the map, it will continue to check for prefix that we need to find. Once there, it will return the object name. By no means this is an optimized solution as it goes through loop of all sObjects till it can find the object. But this is better than having to go through other ways to find same information. Of course, if you come across an easier way then please share.

public class SchemaGlobalDescribe{
  public static String findObjectNameFromRecordIdPrefix(String recordIdOrPrefix){
    String objectName = '';
      //Get prefix from record ID
      //This assumes that you have passed at least 3 characters
      String myIdPrefix = String.valueOf(recordIdOrPrefix).substring(0,3);
      //Get schema information
      Map<String, Schema.SObjectType> gd =  Schema.getGlobalDescribe(); 
      //Loop through all the sObject types returned by Schema
      for(Schema.SObjectType stype : gd.values()){
        Schema.DescribeSObjectResult r = stype.getDescribe();
        String prefix = r.getKeyPrefix();
        System.debug('Prefix is ' + prefix);
        //Check if the prefix matches with requested prefix
        if(prefix!=null && prefix.equals(myIdPrefix)){
          objectName = r.getName();
          System.debug('Object Name! ' + objectName);
    }catch(Exception e){
    return objectName;

Now we can easily use this in developer console to check object name whenever we want. Of course you can take it a step further and create a visualforce page, add a search box and make it available to all developers in your org so they can easily use it (if needed).

String objectName = SchemaGlobalDescribe.findObjectNameFromRecordIdPrefix('500');

Oh wait, we have written the class, we have tested it but we are missing an important step. Remember? Yes, “Code Coverage”. That’s an important point that we shouldn’t miss. This is important not just to be able deploy the code but it’s good development practice to make sure we test our code. Following salesforce page provides information on testing best practices.

So, I have written very basic test class to cover the code written above. You can add more functionality to your class and then expand on these basic tests.

private class SchemaGlobalDescribeTests{
    private static void testMethodPositive(){
        String objectName = SchemaGlobalDescribe.findObjectNameFromRecordIdPrefix('500');
    private static void testMethodNegative(){
        String objectName = SchemaGlobalDescribe.findObjectNameFromRecordIdPrefix('500');
    private static void testMethodNull(){
        String objectName = SchemaGlobalDescribe.findObjectNameFromRecordIdPrefix('101');
    private static void testMethodException(){
        String objectName = SchemaGlobalDescribe.findObjectNameFromRecordIdPrefix('10');

That’s that and now we can easily figure out object name from Record ID prefix.

Please share your thoughts, questions, concerns or constructive criticism.


PHP File Management Script

This class is a manager of server side files and directories.

It can perform several operations on files and directories on the server side like creating and removing directories, creating, updating and deleting files from directories, retrieving the list of files in a diretory recursively, generating a files listing in a HTML page, etc..

The class can also create htaccess and htpasswd files to restrict the Web access to a given directory to a given user with a password.

Code at


Code at

RSCMS – Really Simple CMS

While working on a small site with no database, I was thinking how to make it easier to create small scale, say 3-5 pages, web sites without having to set up everything everytime. To stop having to do this setup again and again, I developed RSCMS which works on a pre-defined structure and generates final HTML pages as needed. All I needed to do was drop a page in templates folder and just update other pages (as needed) to add a link to that page so its accessible.

After creating this, I thought I’d share this class with everyone to give back to this huge PHP Open Source community that has helped me grow this much. You can get code for this class from following links:

Code at

Code at


PHP My SVN Manager

I have often used SVN as Source Code versioning. Its quite a manual process to create new users, groups or repositories. Not time consuming but very manul task. This prompted me to create a PHP application which I could use to do this easily without having to logon to SVN server. This proved to be quite useful as we work on projects as team. So, now every developer can do this on their without having to send this request to me. See, real easy. Any ways, you can grab this code from following links.

Code at

Code at


WAMP – PHP5.3.13 and Apache 2.2 – CURL Issue

I recently installed WAMP on Windows 2008 server; PHP 5.3.13 and Apache 2.2. While trying to use Facebook API, I came across issue with CURL extension of PHP as Facebook API needs this extension. I enabled this extension in PHP but Apache kept throwing an error that it couldn’t load dynamic library:

PHP Startup: unable to load dynamic library ‘c:/wamp/bin/php/php5.4.3/ext/php_curl.dll’-the application has failed to start because its side-bysiede configuration is incorrect

I found many references of it all over and the solution was to replace wamp/bin/php/phpVERSION/ext/php_curl.dll with correct version. For some reason, php_curl.dll that comes with WAMP doesn’t work properly.

I tried many files but in the end one worked for me. Unfortunately, its trial and error and trying different php_curl.dll files and see if those work. The one that worked for me can be downloaded from (Try at your own risk).

Just wished to share this with everyone in case it helps even a single person.