Wednesday, January 11, 2017

Top #5 Things you should know when moving to #LIGHTNING components from Visualforce

Hello New Year,

Those of you who have barely made it to the 1st, congrats. 2016 has been officially branded as the worst bringer of bad news and us, you and me, have survived and entered 2017. So once again congrats on making it here.

Last year, Salesforce shocked everyone by announcing Lightning, a fundamental and drastic change to the very core of salesforce delivery. The message was simple- this was a major transition in the IT services and if they have not already, all the customers would want their CRM on portal devices. When Lightning was announced, it was like relocating the passengers from a completely full Boeing 404, sturdy durable and slow to the superfast Mig 41 that could deliver fast, break the sound barrier and was efficient- only this was mid-air.

This was a paradigm shift, however, you may want to deny it, and it was fundamentally necessary. But like it or no, the shift happened. And suddenly there was a lot of material out there and every other product that was launched henceforth was labeled Lightning. The good old Visualforce developer that I am, stood behind the crowd in anticipation of what was happening. There were talks, there were webinars, there was stuff happening- and all at lightning speed.

Therefore, it took a while to sort through the noise, cut to the very basics and understand how Lightning works. That effort is now presented in front of you in form of five bullet points that will help you transition successfully to Lightning.

And so we begin, the most fundamental tip that will help you understand Lightning is-

1. Don't Panic

The classic #1 tip given for the average traveler across the galaxy comes in handy when we begin to understand Lightning. There is a lot of material out there for understanding lightning, ready-made components to be used in your code. Start small. If you are familiar with JavaScript you are already there. If not, start now.
Let me repeat this for you, JavaScript is the first step in your transition to Lightning. The golden rule to learning a new language is to write the "hello world" code. A simple code that will get the hang of things. Lightning follows the pattern of any Javascript-based programming language, like AngularJS. Familiarity with one is an added advantage, if not, start learning. Once you get a hang of things, it is really fun to work with.

One way to ease into lightning is to create a basic app fit for your purpose. The Salesforce trailhead gives you a good start into the same.

2. Adopt M-VC

We are programmed to think in an MVC model of programming. We write an apex controller that contains the business logic and queries, the Visualforce page that displays the data. 
A Lightning Component uses the same concept of MVC but here the business logic and display view are written together, while the controller is only used to fetch data. This is the pattern followed by a lightning component. If you have been working on Visualforce/Apex Controllers for a while, it will feel odd initially but once you get a hang of it, building a Lightning component is the best thing you will every do.

3. Write Components inside Pages

With Visualforce, we have practiced hard to write pages for our solutions. We over-use the PageReference apex code to navigate users through the Visualforce wizards. Lightning brings with the most important aspect missing in visualforce pages, it brings the inheritance to the table.
Think of this as writing only Visualforce components instead of Pages. You can further inherit that component into another specializes component for specific use.

4. Everything is in the name

One of the early mistakes I made was not naming the components in the log. If you have a large number of components on the same page and all of them are interacting at the same time, debugging them becomes the stuff of nightmares if you do not name them properly. Create a name attribute to the component that you create and then use this name in the log messages that are generated in the code. You will thank me later for this tip.

5. Javascript is Case Sensitive

A moment of pause to all those who wasted an entire day to realize the problem was onClick. Yes, Javascript is case sensitive. Therefore, if you have a habit of using CamelCase or Camelcase, make sure you maintain consistency. This stuff of nightmare pops up at an unsuspecting time, have faced it many times when trying to access the obj.fieldname but it should be Obj.Fieldname

Some resources that will help you ease into Javascript and further into Lightning:

JS the Right Way

Trailhead (Duh uh)!

All the best and as always May the Force Be With you!
Read More

Wednesday, November 23, 2016

The curious case of the custom redirection on Salesforce Console

Every developer worth their salt knows that the easiest way of redirection from a page to another is by using everyone's favorite function

  public PageReference redirect() {
       PageReference pageRef = page.peskyProblemRedirection; 
       return pageRef; 

And the method is called by adding it to the Action attribute of the CommandButton or link, which works like charm and the user is redirected to the page after completion of the action.
So why am I going back to the basics? Because this way of redirection causes a pesky little problem in using the Service Cloud or Sales Cloud console.

Let's illustrate the problem, let's say you have a visualforce page as follows:

<apex:page sidebar="false" showHeader="false" controller="myExampleController">
<apex:form >
<apex:pageBlock >    
         <apex:pageBlockButtons >
             <apex:commandButton action="{!Redirect}" value="Next Page"/>

The controller to this class is as follows:

public with sharing class myExampleController {
  public PageReference redirect() {
       PageReference pageRef = page.peskyProblemRedirection; 
       return pageRef; 

This does what it says, you click a button and it takes you to the next page seamlessly.

The Problem

But now let's see when this page is added to the Salesforce Console.
Let's run the same code inside the console.

1. This is our first page
2. If we take a peek under the hood, we open the link of the tab inside the console and it shows our first page. PeskyProblemPage

3. Do the thing, click on next page and voila, we are redirected to the next page- as expected.

4. But here is where the problem starts- if we take a peek under the hood of the second page, we see things are not as they seem. If we click on the link of our second page as shown in annotation number 2 in the figure below, we notice that the link has not changed as shown in annotation number 3

Why is this a problem? That is because Salesforce does not auto refresh its pages every time and let's say the user refreshes the second page- it reopens the first one because the link still points to the first page. So what works here? The console toolkit, that can be referenced here, tells us that most of the console can be accessed navigated by using a Javascript library.


One solution for this issue is the use of Native OpenPrimaryTab method of the Console toolkit API. So we rewrite the page again using the Console Toolkit API, this time, however, we will set the redirection on the page itself.

So our new Page becomes as follows:

    <apex:includeScript value="/support/console/28.0/integration.js" />
    <script type="text/javascript">
        //Get the enclosing primary tab, if you want to open a new tab, ignore this method
        var openPrimaryTab = function openPrimaryTab() {

        //Whatever the result, open it in the same tab
        var callOpentab = function callOpenSubtab(result) {
                '/apex/peskyProblemRedirection', true, 'Page two');


            <apex:sectionHeader title="Page one" />
                <apex:commandButton onclick="openPrimaryTab()" value="Next Page" />


As you can see, the magic happens using the onclick function that sets the page redirection on a console. If there is an action to perform before redirection, the same function can be used in oncomplete attribute of the button.

Taking this further,

This example above gives us the basic idea of how the redirection works on the console. Let's say you need to generate a dynamic page URL based on the data manipulation in the action method. E.g., send accountID to the new page from the tab. This can be achieved by using javascript remoting and calling the apex method in javascript. Take a look at the UNTESTED code below, that can get you started on exploration:

<script type="text/javascript">
    function getRemoteAccount() {
            function(result, event) {
                if (event.status) {
                        '/apex/peskyProblemRedirection?id=' +,
                        true, 'Page two');

            }, {
                escape: true


The possibilities are only limited by your imagination. Working with the Console in the past couple of years has given a greater sense of many things Salesforce developers usually take for granted. But once you get hang of it, Console is the best product ever made by Salesforce (Yes better than Lightning too!!!)

Have you encountered this problem before? Do you have any other solution? Share your experience in the comments below
Read More

Friday, November 4, 2016

Four secrets to improve the usability of your visualforce/Lightning pages on Salesforce

In the immortal words of a certain machine returning back in time, I am back. For now. After procrastinating for over a year and drafting a lot of rants- I am back with a very important coding lesson for you. For now.

When we are designing a Visualforce page or an app or a lightning component (added that only to trick google) or any web page for that matter, we often tend to wrap up things quickly. Ask anyone on the team, how to design a good User Experience? and the person will immediately throw buzz words like Bootstrap, angular and other useless libraries (did someone squint?)

Ok, Bootstrap, Angular-Js, and all the libraries are really cool and are useful in designing a fabulous UI. They are helpful in creating responsive pages that will work on all the devices but this post is not about those. Nope. For the purpose of this post, all the external libraries and buzzwords you use to decorate your resume are useless. (Adding Angular JS in your resume for a Salesforce consultant position when you don't know workflows is useless too, just saying). Another comment I receive fairly regularly is that- there are a lot many things you cannot do on salesforce. Which is true but still annoying. While there are a lot many things you cannot do, there are still a lot of things you can still do. One of those things is stop being annoying. Moving on.

Salesforce is a customer-centric system, as such, a user is at the center of whatever you do. Whenever you design an interface on Salesforce you have to remember that- someone will be paid to use the thing for 8 hours a day. If you design bad user experience, their job will be harder and reduce productivity and usability. And one important trick to remember designing a form is- DO NOT LET USER SCROLL. Make sure your form elements are reachable by tabbing.

So with that out of the way, let us take a look at the four secrets you should know before designing a visualforce page

1. Separate your data from the background
This is a tip that was given to me by the director of a college play. You clearly mark the area on the stage where you want the audience to focus their attention.
By default, any web system uses white background and text in black. This form is consistent unless you are on the Dark side or environment-friendly when you will use black background over white text. But don't be google when it comes to displaying complex data on the page. All you need to do is clearly separate the data from the background, you can do that by adding a thin gray background to your text or, as Salesforce does it, place the data between neat equidistant lines. If you are not using sidebar and headers, do include SectionHeader on the page. Make sure you set your data in a way, it is clearly distinguishable from the background.

2. Give visual feedback whenever you are processing information
This is visualforce building 101, if you are using a tag from the family of Command and Action (e.g., apex:commandButton, apex:commandLink, apex:actionfunction, apex:actionsupport etc) you HAVE TO use the apex:actionStatus. Don't leave your user guessing if the button press worked or no. There has to be a visual feedback.
You could be extra quirky to indicate what is happening or give an error message. Shiva has a good code for the same, you can use his action status in your code.

3. Take an extra hour to fix the error messages. Keep them consistent. 
Salesforce provides different ways to display error messages. Some are field level error messages, others are page level error. When developing a custom page, spend an extra effort to make sure your error messages are consistent. If you have a server-side validation, make sure it is displayed alongside the field instead of the top of the page. Don't make the user scroll the whole page looking for the next error message. Remember, someone will be spending 8 hours looking at the page you are developing. The early they understand where the error messages are displayed, the quicker they will adopt.

4. Place the buttons on the bottom as well as the top of the page.
This is a common problem in the majority of the visualforce pages. People will provide multiple sections of a form and them make sure scroll all the way up to press submit. Bad idea. Also if the user wants to just fill the required fields and then submit- which is also ok, don't make them scroll all the way down to look for the submit. Be smart, place your button on top as well as the bottom. Besides, give the user a choice and they feel included in the design.

So in summary, design user-centric system that they can adopt faster and learn quicker. Most of the Salesforce implementation fail because users do not adopt the system as they should. Make their job easier, not harder. A twenty-year experience sales person should not be bothered to learn a new system just because his job wants him to, instead, design the experience so much friendly that the said person should pick it up on the job quickly.

Hope that helps in any future design you create. If you have any other tips, share in the comments below.
Ok. Bye. For now.

And in the mortal words of a immortal machine traveling back in time, I will be back.
Read More

Monday, May 23, 2016

This is where you start: Salesforce Platform Handbook

 One of the early challenges that I faced while learning Salesforce, almost eight years back, is that it was too big of a cookie to eat. It still is. Salesforce Platform is huge- it has many products, integrations, different design patterns, different coding standards and Reid Carlberg is always experimenting with something next!!!. On top of that, new developers and admins are walking into the fold with their ideas of coding, the uncertainty of the job and a massive task at hand- learn this new technology that starts with a dot com. The task is daunting. 
Salesforce on its part is very forthcoming to help the community- with its trailhead, online videos, webinars, and certification programs. But too much information in itself is not a very helpful start of a career. At times like these- you sometimes wish, you could take a deep breath, pause, reflect and say - ok this is where I start.
That moment is exactly why the new book - Salesforce Platform App Builder Certification Handbook is written for. This is where you start- this book is going to do enough to get you started, your first gear, your first step, your first app. It is going to give you the taste of the whole platter that you have to consume, one bite at a time. This book is for the beginner admins who want to know if Salesforce is more than the keyword, this book is for the beginner developers who want to jump head-first into the platform and this book for the professionals who moved from different technology and have a lot to unlearn before accepting Salesforce.
In a way- this book is the second edition of the Developer Certification Handbook that was published in 2012- but since the exam has changed, so has the syllabus and so has the book. Salesforce Platform App Builder Certification Handbook is written in the pattern of the exam and is updated till Spring 16.  
It will help you to prepare for the platform app builder certification exam. We begin with designing the object model and look at the options for building page layouts. It will guide you through designing the interface while introducing the Lightning Process Builder. Next, we will implement business logic using various point and click features of We will learn to manage data and create reports and dashboards. We will then learn to administer the application by configuring the object-level, field-level, and record-level security. These and many other fundamental topics are in place for you to learn. By the end of this book, you will be completely equipped to take the Platform App Builder certification exam.
The book is out there for you to buy. 
This is where you start. All the best.
Read More

Thursday, July 23, 2015

Understanding the Internet Revolution

Man is a social animal, this was the first lie they ever told you in your history classes. If we look at the human history going back through the dark ages, we understand that man is anything but a social animal.
The agriculture revolution gave control of food in everyone hand and we started building societies, bringing people socially together. But when societies formed it brought all sorts of people together and caused all sorts of conflicts between them. Somewhere in the middle ages, few smart people realized this and decided to kick start a religious revolution. They established common guidelines for communities to work cohesively without stepping on each others foot. But they could not achieve this without control of information. With control comes fear and with fear comes faith. They established Churches, Mosques and Temples and controlled the information to reach heaven.
But the voices of dissident did not merge, not easily, they just were suppressed. A few kings got on to the idea and decided to infuse this religious fever in their governance model. The entire Europe was established on the principle. Now the religious revolution had fear, faith and power to do stuff. The voices of dissident were brutally killed and the fear increased.
As we entered the industrial revolution, fear gripped the nation and so did faith. Together they created a working class that dreamt of a better world. At that time, two teenagers were working on another Book that would rock the world, they were Karl Marx and Friedrich Engels. The book they authored was 'Communist Manifesto' and they formed the labour revolution.
The labour revolution gave power to the voices of dissident that were hiding till that time. The labour revolution and the religious fever gave rise to democratic system. People decided time was for change and a new form of system was brought out. The democratic system was gift wrapped to the citizens as a government of their own. It was a government that majority agreed. They elected representatives and send them in the parliament, not knowing that the game itself was rigged. These elected representatives worked for the greater good but they were part of the old system, were control of information was essential. This new system was using the same old principle of withholding information thus causing fear and faith among the masses. That gave rise of conspiracy theories and the voices of dissident were termed lunatic and unpatriotic. 
A young college drop-out was working his way to do something he never expected, this was Bill Gates and he was trying to sell a personal computer. When he introduced the concept of Personal Computing, people laughed at him. Why would anyone need a personal computer? They were happy with computers at universities and workplaces but computers at every home? That was madness.
But that madness ensured. Bill Gates (knowingly or unknowingly) kick-started a computing revolution (Although the credit for computer goes to Alan Turing, I personally believe that the idea of Personal Computer was introduced to the world by Bill Gates). Steve Jobs lost the race in computing but regained his spirit in mobile computing. Between them they brought the power of computing to individual people.
The voices of dissident now had a platform. A free and fair medium that was so vast that no one could control and thus the cloud was born. Internet revolution broke the backbone of traditional institutions that relied of information control. These institution are religious, corporations and even Governments.
The power of internet brought with him the Occupy Protests, WikiLeaks and many more to come. What does this mean for business?
It means we are standing exactly where Matthew McConaughey was standing on the Millers Planet in the movie interstellar. What we are seeing as mountains are waves, big tsunami waves and they are not coming towards us. Like the Millers planet, our world, everything we know is moving towards them. We have already started descending into the next phase in human social revolution.
The information is no longer controllable, the dissident voices are no longer silenced. The problems can no longer be put on back-burner. The governments are running scared, trying to control the internet but this is an illusion. Social Media and Cloud Computing are two by-products of this massive revolution. We are moving away from the traditional computing model. We are moving from the controlled model of dispensing information based on location and time. It can still be achieved and is required for security but that is just an illusion.
If your 'social media' strategy does not include 'listening' to those voices, you are being pulled near that wave. If your corporate strategy does not include social media you are being pulled into that wave. Your employees, your customers and your partners are on social media. They are carrying devices that could leak complaints about you at any given point of time. How far can you control them?
The changes internet revolution is bringing are disruptive. They are here to stay. Anyone who pretends otherwise is still believing the waves are mountains and very far away.
Of-course this article is completely speculative and has no real evidence but we have already seen the changes happening around. We can always pretend that nothing of that sort is happening and go back to our life.
But the world will keep on moving and with it bring a new wave of change. How far we prepare for that change completely depends on us.
Pic: Luis Llerena 
Crossposted from Linkedin
Read More

Thursday, March 26, 2015

Leaving a Learning Trail

One of the most worrying aspect of an client engagement is what comes after the successful deployment.

In one of my previous role, I was asked out of the blue without any prior warning to deploy a large chain-set containing 19 objects, some close to 380 fields, with 9 interlinked-relationships. Along with that I was to cleanse the data from legacy systems that amounted to 6 digits of records. And all this without a proper plan (I was the one who was supposed to come up with a plan for this) and two days prior to my extended vacation for Diwali. And that too when my mom had promised to make my favourite sweets.

But even on that day, when I prepared the plan on the 14 hour train journey from Delhi to Pune and then successfully deploying the whole package after relishing on the sweets, I was not as worried as I always am when I am told to do a Train the Trainers session at the clients office.

It is always good to have a train the trainers session and a good company understands that. However when it comes to estimates for a proper train the trainers session presents with difficulty. First, if its an implementation to replace their existing system (or worst with no system in place and moving from the DREADED EXCEL Sheets) a week worth of training is never sufficient. Not to mention the Users knowledge of Salesforce in the first place is very less and then telling them about the brand new system that we have developed for their convenience.

The point is, the exercise is fruitless which worries me. At the end of the session the customer promises to hire a good admin or if they have an admin, he promises that he will get certified and ask others to get one too. Somewhere down the line, it fails, people get confused using the new system and get back to their DREADED EXCEL sheets. This problem happens with a lot of Foundation customers as well.

When Salesforce introduced Trailhead I rejoiced, finally, I had something that I could give my customers, end users, new admins that was cheap (free duh), effective and a fun way of learning Salesforce. All I had to do now is go to the train the trainer sessions and verify they have the necessary badges to show us.

The trailhead website is very neatly organized and is very easy to navigate. If you are new to Salesforce, you could start with the basics track. this trail leads through 6 steps of Introduction to the platform, Data Modelling, Data Security, Data management, Formula fields and UI customization.

Not only that but Salesforce has now released amazing trailhead modules from programming track too. There are two programming tracks one for visual app development and another for Programmatic app development. 

The visual app development track consists in tutorials for process automation, Salesforce 1 basics, Setting up Chatter and how to handle change.

Read More

Friday, March 20, 2015

Code-pattern for Creating Mind-blowing Tabular Reports on Visualforce (With Sample code) has a mind-blowing reporting structure but it limits on data that is available on the system. Can we report on Data that is not present in the system?
For e.g., in a time-sheet management system, can we identify the people who have not filled time-sheets for a particular day? Can we report on data that is not present in the system? Can we identify records that are not created?

There is one thing I have learned working on platform for last 7 years, there is No No answer in Salesforce. Think a little bit and the answer will reach you. It is somewhat like climbing mount Everest, can you do it? Sure yes, in how many days depends on how fit I am (or how crazy I am)

Ok that Everest thing came up because someone did ask me that a few weeks back, moving on. Someone did also ask me about creating a report on missing details and I gave it a thought. The short answer is Yes we can, the long answer is we write a Visualforce page, anyone can tell you that. But what I really wanted to do was create a reusable code that I could use for a generic tabular report component.

The code is fairly simple, the pseudo code for the code is.
1. Generate a set of String for Rows
2. Generate a set of String for Columns
3. Prepare a map with Key as Row+Column and store the data accordingly.
4. Create a Dynamic table on Visualforce.

Apex Class for the page

public with sharing class TabularReportController {
    public Set rows{get;set;}
    public Set Cols {get;set;}
    public Map dataMap {get;set;}

 public TabularReportController(){

  public string getURLParam(String paramName){
            return ApexPages.currentPage().getParameters().get(paramName);
 //Get the data for the rows
 public Map getrow(){
     return new Map([Select id, name, Accountid from Contact]);
 //Get the data for the columns
 public Map getColumns(){
       return new Map([Select id, name from Account]);

    //This is where the magic happens
 public void prepareDataForReport(){
     rows= new Set();
     cols= new Set();
     dataMap= new Map();
     Map columnsData=getColumns();
     Map rowData= getRow();
     for(Account a: columnsData.values()){
         for(Contact c: rowData.values()){
             String key=; //Key is the key in which we set the data that we want to display.
                //Do some hazy logic here. This is where the key lies, you perfom your calculations and simply prepare the data
                //For display
                //For this example I am going to check if Contact is related to account

Visualforce page for the code

 <apex:page controller="TabularReportController" sidebar="false">  
 <style type="text/css">  
      .Related {  
            background-color: #0B610B;  
            color: #FBF8EF !important;  
            background-color: #A4A4A4;  
 <apex:sectionHeader title="Documents" subtitle="Report"/>  
 <apex:form >  
 <apex:pageBlock id="TheTable" title="Are the Accounts and Contact related?">  
 <table border="0" cellpadding="2" cellspacing="2" style="table-layout:auto" class="list">  
      <colgroup span="2"></colgroup>   
      <thead class="">  
      <tr class=" headerRow">  
           <th class=" headerRow" scope="col" colspan="1">Contact</th>            
           <apex:repeat value="{!rows}" var="row">  
           <th class=" headerRow">{!row}</th>  
  <tbody >  
 <apex:repeat value="{!cols}" var="col">  
 <tr class="dataRow">  
      <td class="dataCell" colspan="1" style="white-space:nowrap"><span>{!col}</span></td>  
      <apex:repeat value="{!rows}" var="row" >  
&lt;!-- This is the Key, so to speak, for the entire page. Generating the key on the visualforce page --&gt;
      <apex:variable var="key" value="{!col}{!row}"/>  
      <td class="{!dataMap[key]}">{!dataMap[key]}</td>       

You can see the output of the report here

You can enhance the code using the same structure. Here are couple different thing I tried
  1. Adding a link to the data using wrapper
  2. Model window editing for the data
  3. Adding complex many to many relationships
  4. Plotting records that are not present

The list can go on.
Read More

Monday, January 26, 2015

Hands on for Salesforce Lighting Connect (External Objects)

Salesforce External Objects is a new tool that has caught my attention in recent times. Those who spend their day listening to words like REST, SOAP, Integration etc. the following information for you.

Salesforce External Objects is nothing but the out-of-box implementation of ODATA architecture. ODATA is a open-source data transfer standard backed up by the Empire Microsoft (they are good guys now). Instead of an architecture of sending messages back and forth using HTTP like REST, ODATA focuses on the content of the message over HTTP. ODATA can also be compared with ATOMPUB format (RSS feed format). However ODATA is useful in sending tabular or data over HTTP, that example can also be sorted, searched, filtered and other URI conventions.

In this second post on Lighting series I am going to delve deep into how Lighting Connect lets you access external data right into Salesforce. If you were living under the rock or in some place with no internet connect, here is the summary of what you need to know about Salesforce Lighting.

In this hands-on I am going to pull some real time data into Salesforce.

Step 1: First thing we need to find out what external databases are available for us to connect to. Salesforce supports ODATA V2 databases. A quick google search brought me to this page that has some live example. (

Step 2: If you go to Services on the site, you will find OData (read/write) that is online.
The link opens a URL ( hold on to that for now, lets open Salesforce.

Step 3: As always login to your developer account. (Note: for this tutorial and any tutorial on Lighting, please get a fresh org. As I learned the hard way, an old sandbox did not have this feature in built.)

Step 4: If all is well, you will find External Data Sources and External Objects

Step 5: We are going to first add an External Data Source and point it to the OData. Go to External Data Sources -> Click 'New'

In the form you can specify the Name and Label. The Type should be Lighting Connect: OData 2.0 

Step 6: Once you select the type, it will have further fields like Server URL. Copy the URL we have in Step 2 above and click Save.

Step 7: Once you click Save and all is well you should see a detail page with options to Edit, Validate and Sync and Delete

Step 8: Click on 'Validate and Sync' it will scan the URL and get you all the objects available to Sync with Salesforce. Note: if it does not sync or you get an error, it will be shown in Status field.

Step 9: I am going to select Product object to sync. Select your objects and click on Sync. You should see one record in the External Object section.

Step 10: Now comes the best part, go to Create-> Tabs and you can find our objects right there in Salesforce object tabs

As I have understood in past few days, Lighting is a vast thing. In the next few weeks, Ill be posting one blog about the Lighting Framework. Be sure to subscribe to the blog and if you have any comments, mention in the comments below.

SforceNinja Out.

Read More

Tuesday, January 13, 2015

The Monk who sold his Computer for the Cloud

The first computer I ever saw in my life was a desktop that my father gifted to me during my second year of computer engineering. The specifications were a 1 GB of RAM, 40 GB HDD, a modest LG monitor, an Intel P5 Dual Core processor and an Inverter (this came separately and since we were in India, a battery inverter was necessary). The installation was so space consuming that we had to invest in a computer table (no other place could accommodate this machine) that had options of keeping CPU and inverter and Printer under the table, a foldable keyboard and mouse holder and a monitor. This was ten years ago and by the standards back then, my father had purchased the best computer in town.

My father is a perfectionist, and hence he insisted on building a shelf/ library over the table that would complete the look of a decent computer workstation. This was the computer that accompanied me during my engineering days. The endless hours spend over playing with MS Paint, writing hacks in Excel and sending it to friends. I used to write first draft of my stories on the machine, I used to listen to songs for endless hours. Purchase DVDs and listen to them until they are scratch. I had 9 pen drives, with which I used to carry my data to my college.

The last three smartphones I had support 64GB of memory space. They all had Quad Core processors, were much faster than my computer and could fit in my pocket. The things that I did with my computer, now I do with my phone but I do it without getting chained to the workstation. I play my favorite GTA Vice City, over again on my phone. I left my home town around eight years back and have been travelling since. Carrying a phone with me was much easier than carrying the machine. I remember having 12GB of songs on my Computer. Now, I use the paid service of, the online music station. And you know what? Even while travelling on the cold foreign streets of London, the friendly voice of Arijit Singh accompanies me. My data is safely backed up on cloud servers and not just mobile data. The old college files, the projects reports everything.

My brother called a few days ago and asked me if he can sell the computer and buy something new. That call provoked this post. I sold the computer and have moved on.

Because many people asked for it, updating the post with the common task I needed computer for that have been replaced by the cloud.

1. Editing my Book

Thats the easiest thing anyone can relate to. How do I create documents, the dreaded excel sheets and powerpoint presentation. The common answer would be Google Docs but somehow in past few days, I am not really in Moodle for Google (neither am I switching back to the old nemesis microsoft). I used Zoho Writer to edit my novel online. I preferred their services much better than other online tools.

2. Create Graphic for the blogs

Creating graphics is as old as computer itself. And when it comes to creating graphics, no one does it better than Photoshop. Photoshop was hard to replace but two services have given me more joy that anyone ever could. One is and Canva. Canva helps me layout stuff with text, like the title graphic of the blog while lets me create and filter images easily.

3. Creating presentation

When I am not doing anything, I am busy creating presentations. I love those things that move around. You can see some of the things I created on my site showcase. Most of the presentations on the page are created using the online 3D presentation maker. Prezi gives an extra dimension to the presentation and that wow factor helps.

4. Making Infographics

I have used many corporate tools for making infographics. The best one was obviously illustrator, adobe knows how to do stuff right. But then can I make infographics online? I tried with pixlr but since there was a screen limit with their editor, making a long infographic like the one for cloud computing was a tedious job. Just when I thought, I am losing the challenge, ta da, came to the rescue. Cacoo has an easy to use interface where you can create beautiful graphics for free. They offer 25 diagrams on the free license which is really cool.

5. Sharing files and photos

One of the many things you need a computer and those little USB drives is transfer of files. During my college days when I did not have a computer, I used to carry a rewritable CD in my bag and borrow CD writers on my friends computer to burn disc. Things changed and we now have those USB drives. So the real question here was how do I transfer more than a GB of file? Now in real world scenario there are very few things that are more than one GB, however lets say I wanted to transfer a heavy file? And there Dropbox came to rescue. What was more with the camera upload feature, I did not have to do anything. When I took photos, they were safely upload to dropbox and all I had to do was share it with my friend.

6. Watching Movies

When was the last time you stepped into a DVD store and purchased a nice DVD, picked up a bottle of whiskey and made some pop-corn. If you never did, I highly suggest you do. Anyways, so since this was a post computer world, the best alternative I found online was It is a on-demand movie site that streams bollywood movies. It also streams selected english movies. I recently got a subscription for NetFlicks which streams English films and serials.

7. Listening to Songs

Listening to songs while doing stuff is one of the many things one can do. However, iTunes has already brought those on cloud. Just like movies, listening to songs is also a regional thing. One of the best service I use regularly is It streams not only bollywood but also regional marathi songs. For Internet radio and songs I switch between Spotify and Pandora

I am the monk who sold his computer for the Cloud. Are you?

Image Credits: Flickr (CC Label for Reuse with Modification)
Edited Using:
Read More

Saturday, November 22, 2014

Everything you wanted to know about Salesforce Lighting Connect (External Objects)

The world runs of Data. Having correct data can determine if your business succeeds or fails. Since the emergence of Cloud Computing, Data escaped its normal prison of sitting on servers and became relevant. But the most important aspect about cloud was data was not interchangeable. I.e., It escaped the prison but was trapped in a zoo. In a large organisation if there was a need for using more than one system to manage data, it became a development nightmare. Not to mention maintaining multiple connections and data consistency between two systems, middle-wares (if any) and still keeping it under the governor limits.

Salesforce Lighting connect lets you overcome this limitation by using the (soon to be) global standard OData protocol. With external objects you can connect to an external data source like SAP or any other database that uses OData protocol or a simple URL. What this means is you can have orders in SAP and customer Data in Salesforce. Both will be connected together and you can use it with very less or no effort.

oData - New Page (1).png

What is OData Protocol?
OData was first proposed by Microsoft and was released in March 2014 by OASIS (Organisation for the advancement of structured information Standards). In very basic terms OData is the common language in which the web will talk to each other. This is possible even today by using REST API and SOAP but these API are for processing information, having a separate protocol for only Data exchange helps in many ways. First, it is easy, as easy as creating your own object in Salesforce. Second, it is auto-synced between the two system.

How does Salesforce use this OData?
Salesforce has introduced a new concept called External Objects. Earlier we had external ID field that stored ID for external databases. This was very useful when loading Data but with External objects the data will be accessed from the external system and displayed in form of Salesforce. Thus keeping it in Sync. The following diagram illustrates the entire process.
oData diagram

What do we need to access external data?
Before we learn how to create an external object, let us look at what the external database should provide in order to make this connect happen.
There are two fundamental things we need to access the data. They are
Data should be in open format like oData.
It should be accessible via the internet (i.e., via cloud)
For security, it should support OAuth.

Do external object support SOQL and SOSL?
One of the most obvious feature of external object is ability to search them. We can use the standard SELECT, WHERE, LIMIT and OFFSET clause we are familiar with for SOQL with the external objects. Obviously it is limited to the external data service to provide accurate data.
For SOSL, the external objects support FIND, IN, RETURNING, WHERE, LIMIT and OFFSET clauses.

Does it support Relationships?
Where would we be without relationships? Yes, External objects support a limited type of lookup relationships like Basic Lookup, External Lookup and indirect Lookup.

The standard lookups that we currently used are extended on the external objects. The lookup to an external object do not support cascade delete or lookup filters.

External Lookups:
External lookups are created on Standard, Custom or external objects using the External ID field (and not the standard Salesforce ID)

Indirect Lookups
Indirect lookup are external objects that are child to Standard Salesforce objects using a unique External ID field.

However, a point to note that child records of external object will load depending on external database and network speed.

This is everything you need to know about external objects. In the next post we will actually create few objects and show seamless integration between two system. What do you think of lighting connect, have more questions? Post them in comments below.
Read More

Thursday, November 13, 2014

Have you met the Ghost Records of Salesforce?

This post is very old but it is long overdue. Have you seen the Ghost records in Salesforce? Whenever there is an auto-number field on an Object, it suddenly seems to have gaps in between? For e.g., if you have a auto-number set at 00001 and the next record it creates is 00004. These gaps are sometimes attributed to people who create records and delete.

Auto-number fields
Lets talk a bit about auto-number. Apart from the part that they are cool, they are also very stubborn. An auto-number field resets only once in its lifetime and never turns back. When an auto-number is incremented it does not go back, even if the record is deleted.

So when you delete a record that has auto-number field on it, it will not decrement it by 1 but instead create the gap.

Ghost records
The real crux of the issue lies when developers write unit classes. Developers always create dummy records for testing. The test execution runs in a separate context than the main Salesforce. These records are not seen in the system or recycle bin but their data remains. Thus auto-number is incremented.

Like always there is a solution (Since Spring 14 that is. Spring 14 is the ghost buster in this case).

Go to Setup-> Apex Test Execution-> Option

Since Spring 14, a new option Independent Auto-number Sequence is available. For some reason it is turned off by default and can be turned on to prevent this. Once it is on, test methods won't affect the auto-number sequence.

Ideally, there are very few cases when this problem can happen in Production. The only time a unit test is run in the Production is during Deployment from Sandbox. Avoid running Unit test in Production. A proper deployment plan can also prevent redeployment of same classes and this prevent running.

Seen any ghost records lately? Mention in the comments below.
Read More

Friday, November 7, 2014

The OnePlus One that I am Proud to Have

We live in a world where smart phones are produced faster than universe can produce smart people. With the avalanche of smart phones that come your way and almost every week a new smart phone has a 'launch' it is very hard to stay enthusiastic about it for a long time.
I appreciate the Apple Fans in that regard that they wait patiently and enthusiastically for a phone that is two years late in terms of innovation.
As a disclaimer, I am a Samsung fan boy and while the phones may be dismissed as cheap plastic, it hardly matters for me what the phones are made up of as long as I can chat with my wife on Whatsapp and watch the trailer of the avengers movie at the same time. Yes, as buggy or half baked the multi screen maybe I still like the fact that I can do more than one thing on the screen of my S4.

I started my journey with Galaxy S2, a much awaited and stable version of android that added steroids to mobile computer. When Samsung released the 10.1 tablet, I brought it out because that helped me watch my shows at night. Then it all spiraled upwards till Galaxy S4 when the advance multi-tasking feature grabbed my attention. The pop-out video player added another level of excitement. But then slowly this excitement waned, there was nothing new in S5 save perhaps the water proof feature. That's when this one caught my attention.

I am talking about the Oneplus one, the self professed flagship killer from a relatively new Chinese manufacturer called Oneplus. Chinese? Did I say, yes and you heard it correctly. OnePlus is a relatively new company that has launched One as the first phone in the market. Why is this phone so special?

There are a couple of reasons,
One. This phone comes packing with Cyanogen mod CM11, the one ROM that many people install after rooting, bricking the warranty. Cyanogen who made android better than Google themselves is build into the phone as a firmware.

2. The unique invite system that they have. OnePlus basically isn't available retail and can be purchased only if someone invites you for buying it. So when getting hands on the phone is a difficult task you want it even more.

It was impulse decision when my friend asked me if I wanted OnePlus invite and I purchased it. How much did it cost? Only 273£ and I ordered it in UK. It didn't burn a hole in my pocket nor put me on the hook for 2 years like the Note 4 I was planning on buying.

Did I regret it? Not at all

It took seven days for the phone to arrive at my office and the first day was exciting. So much that this was dreamforce week and I was more excited about something other than dreamforce that week. Now this post is not about the specifications of OnePlus one, there are plenty of those floating around. But this is about my experiences around them.

The packing
When the phone arrived in the mailbox, I was really excited. The packing was decorative, like a jewelry box.


The Operating System
The operation system is arguably one of the fastest one I have seen. It responds to touch in an instant and is blazing fast. It took me five more minutes to dig into all the customization features on the phone and they were a lot. An overnight spend and I had customized this beast for my use.
Since then, OnePlus has never disappointed.
The only feature I am missing from my S4 is the multi view option that would allow me to chat and watch videos at the same time. Other than those, OnePlus does everything better.

Perhaps for me Camera is not the very interesting thing to look at. Sure any mp after 8 is good for me but I never got good pictures anyways. During the recent weekend traveling in London, OnePlus camera was praised more than often.

These are some of the HD pictures taken with OnePlus during the trip to London.

The Looks
Perhaps for a smart phone, looks don't matter that much as long as it augments your life and helps you multitask, the OnePlus becomes a winner on that front. It looks beautiful with the granite like back cover and its sleek design, I have received more compliments the more I use it.

So there you have it, there are other features but I don't really care about those. OnePlus has changed the way I look at smart phones in a complete different way.

Do you own a OnePlus? What are your views mention those in comments below. Just so you know, I don't have any invites to give away.
Read More