Sunday, 30 November 2014

Custom Star Rating Component Using Visualforce In Salesforce

Have you ever met with a requirement where you had to Rate list of records in salesforce and store the ratings related to Individual user and then do an average rating based on rating for all users for the records ?The records that I refer  to may be your custom objects ,or leads or may be your Accounts or opportunities .Providing ability to Rate records is one of the common requirements if you are building a site where you showcase your products .Salesforce knowledge article provides this facility but the solution we will do here will be rating custom object or standard object and we assume you don't use knowledge module for your purpose .

Our approach will be to use a simple plugin that I liked very much and special thanks to the actual author who has developed this plugin Kartik Visweswaran.I salute his work and my work is just integrating his work with salesforce Visualforce Page .

Lets get started with simple demo that he has hosted on his site ,the demo link is as below

Lets quickly grab his plugin from the github repo .

Assumptions for this work

I have created a Junction object between user and Account and have named it as Account Rating .The Account Rating object has a custom field created of number type Rating to store the rated no from visualforce interface

Visualforce Code 

We will import all the jquery,CSS,bootstrap plugins into the static resource and reference the same in the VF.The entire code is as shown below

The meat of the code above is how we have used script to call javascript remoting function to upsert the junction object

Apex Code

Let me take some time in explaining this on what we have been doing here,

The Input HTML-5 tag has a javascript that detects when the rating changes .Once the rating star is clicked we call js remoting to upsert user rating for the Account.The demo page appears as below link .Note I have kept code very simple .and may be once I have time i will enhance this to make it generalized for any object and fields.
I have made a small unmanaged package in case you want to pull this and play in your org to see how this goes

Use this URL to install the package into any organization:

Note: If you are installing into a sandbox organization you must replace the initial portion of the URL with

Also a small video I have attached to explain the functionality clearly .Also note from karthik demo you can add all style elements .Check his demo page for more styling .The attributes can be configurable as well

Enjoy coding .....

Sunday, 9 November 2014

Learn how to use Salesforce Communities Designer for Self Service Portal

Salesforce community portal have been in use for long time, but was limited in offering pleasant features and specially custom configuration. To introduce as new feature, lot of additional works needs to be done, both from development and design perspective, which include using HTML, CSS and Javascript on top of Visualforce.

Clearly powerful user-experience and clean user interface adds high user engagement. In person, we have spend weeks to leverage an impactful customer experience with Salesforce Communities

Salesforce introduced community designer and have fascinated me in person, I have been working on this platform for about three year, and I find this tool be very productive. I teamed up with +Harshit, and decided to write this blog post here explaining how to Salesforce Community Designer Tool released in Winter'15.

To explain a functionality, I am choosing a business scenario, covering business activity in an financial institution, and covering mundane activities like resolving credit-card/loans issues. My objective is to explain this all with no-code, and rather deal everything with 'Point and Click'.


1) Lets set up a developer org . sign up for an org from

2) If you are not familiar with communities, we recommend reading this setup guide here .

3) Knowledge articles is the soul for this whole set up. Get some coffee and go to this setup video here

Having installed Prerequisites (Note : three of mentioned resources, are mandatory) , we will look up Salesforce Community Builder and Templates, to set up Self-Service Portal

Navigate to Set up>Communities>All Communities

Note : As shown in picture above, two new additional setting are introduced as  ‘Administration Settings’ and ‘Community Management’

Salesforce Community Templates

Primarily, three important templates available to jump start, but I would like to share the amenities, each templates offer, and make choice easier for you.

1) Kokua - Uses data categories, case and Salesforce Knowledge.
2) Koa- Designed for Mobile, features include, articles search and case management.
3) Napili- Offer most features, with Q&A, Knowledge Articles and Case Support. Clearly, I’ll use this template moving forward

Pickup template of your choice, In here, I have created a community named ‘FunCommunity’ as you can see in drop-down,

Setup Navigational Topics

Got to Community Setup shown as above and you will see salesforce settings screen similar to
one shown below

Bind Topics

Go to (Setup -> Topics -> Topics for Objects) to bind topics to every knowledge article. Clearly, this make it easier to locate or navigate in the community

Screen shot below explains, how to add banner images for each topic. I have created three topics for here to demonstrate, Credit Card, Debit Card and Loan Processing

Assign Data Category

Locate arrow on top-right, to assign data-category for each topic, in the picture below    

Featured Topics

Every featured topics, pop as thumbnail on homepage, add feature topics here

Video Summary

With that said, you community portal has taken shape with pure configuration and 'no-code' involved. I am compiled these steps in a video and discussed some more feature(s). Feel free to provide us feedback and share your knowledge with us.

Tuesday, 14 October 2014

Journey from blogger To author

Sorry for not being so much active here but I have a strong reason that I am sure you will forgive me .I am excited to inform I was given an opportunity to author a book on explaining administration essentials of CRM .I have completed the book and I am eager to get some feedback from readers .

It was not easy job working on this after office hours but this was true unique experience and challenge .

Who This Book Is For

This book is targeted at expert administrators or professionals who are new to Salesforce and want to learn the various features supported by the platform in a short space of time. The book can also be used by professionals preparing for Developer and Administrator certification exams from Salesforce.

What You Will Learn

  1. Understand how licensing, profiling, and security settings are set for users
  2. Perform data modeling and use Salesforce components such as workflows, approvals, validations, layouts, and record types to solve business problems
  3. Get to know the reporting basics and use Salesforce analytics to build reports and dashboards
  4. Troubleshoot common challenges that administrators face in real-time businesses
  5. Get to grips with the Sales Cloud and Service Cloud features provided by the platform
  6. Utilize tools such as the data loader to load data into Salesforce
  7. Load data using an external ID and understand the importance of Excel VLOOKUP
  8. Get familiar with the overall administrator responsibilities for real-time applications

salesforce is one of the leading platforms for developing cloud-based applications. Primarily, Salesforce is designed for managing the sales processes of an organization, but the platform can be leveraged to develop custom applications. It runs on the platform. With the advantage of having reduced development costs, we can deliver applications in a very short time span. With this book, administrators will learn to tackle a lot of things that pop up in their daily routine.

This book is a comprehensive guide that explains user management, profile management, and the basic building blocks of an application. The book proceeds by explaining the troubleshooting skills needed for an administrator. The best practices and disciplines of data loading are discussed in detail. The book concludes with an overview of sales and service cloud features so that the reader is ready for the advanced configurations of this module. By the end of the book, you will be a competent administrator who can manage and maintain the Salesforce data of your organization successfully.

To get a sample chapter you can visit below link

You can also purchase both ebook as well as printed version from amazon or packtpub.

Would love to get some feedback on how this book is and remember this is for people who have just started using salesforce CRM and are completely new 

Sunday, 7 September 2014

Invoking Apex Callouts through Visual Flows

Few weeks back I was attending a Webinar on Advanced Flow From SFDCBill(Product Manager Flows .I was quite surprised to discover flows are very powerful feature provided by the platform for the administrator to configure the business logic .

My friend Rakesh has been blogging lot of use cases of flows for Salesforce 1 and using chatter objects .You can refer his blog for more details on the work he has done .I have learned lot from those and I am thankful to him for sharing his experience with visual flows through his blog

One of the things that came was invoking callouts or webservices through flows and SFDCBill was able to communicate the design that one needs apex and process plugin for invoking callouts directly from the flow .I did a quick online search to see if this has been demonstrated  and was not able to get some good resource so i thought of sharing a sample tutorial on how to invoke callouts from flows directly.

The more information on the process plugin can be obtained from below URLs ,

The Process plugin is an apex Interface and that needs to be implemented in order to pass request into the apex class from the flow input or screen and the apex interface returns the response back to the flow.

Lets discuss how we can make a web service or apex callouts from flow directly .

1)Our first step will be to write the apex plugin class that makes a webservice callout to external website and process and makes the data ready for passing back to the flow.

For webservice part I have taken a sample REST service provided for free for learning purpose from the website

The web-service takes input of state and city of US and outputs current weather condition in the form of JSON objects .Note that you need to sign up and generate an API key for your use .

The input of state and city can be taken from flow screen and it can be passed directly as request parameter to the apex class .

Here is the complete apex class for the flow plugin

2)For JSON parsing ,I have used another class shown below ,which handles parsing of the data .This can be easily generated using by providing sample response JSON.

Lets dig into the creation of flows ,

Visual workflow basics can be studied from following resources

3)We will need below three components 

i))Input Screen to take data of city and state from User need as input for our webservice
ii)WeatherAppApex Plugin we have just developed using apex
iii)Output Screen to display the result

The input screen will have two fields to capture input 

The Apex Plugin will have a mapping for both input and output from result.The below screen shots show the input and output mappings .Note for output mapping for further usage of output  parameters flow variables are created

The output Screen is last piece to display the results .

Now lets see the outcome of this work in below video

I hope you enjoyed this tutorial and looking forward to your comments below .

Please note error handling in code and Test classes are left as it was just a POC code .Be careful to take care of all these when implementing for client code .

Happy Coding !!!

Sunday, 10 August 2014

Refreshing Parent Window of Inline Visualforce Page from Child Window Opened from Inline Visualforce Page

The problem statement is From Inline Visualforce We need to open a Child window and then from that child window we need to refresh the Parent window of the Child window or redirect Parent window of the child window .

Last night ,I was struggling on how to redirect the Parent Window from the child window that was opened from the Inline window 

I tried hard on how to solve this ,but finally last resort was to post the query on salesforce stackexchange .The below is the link for the same

The error was due to Javascript security of web browser .

I tried the below script on the child window


  function test(){


Unsafe JavaScript attempt to initiate navigation for frame with URL '' from frame with URL ''. The frame attempting navigation is neither same-origin with the target, nor is it the target's parent or opener.

The browser security features don't allow navigation from child window directly since visualforce and standard detail page are in different domain.The above error is due to the same feature .

Stackexchange has really expert professionals and Eric suggested me the below solution.I am posting the same so that helps others

The Inline page on the parent window has the below code

<apex:page standardController="Account" extensions="Accountctrl">
<apex:form >
  function openwindow(){"/apex/pagereal", "myWindow", "width=200, height=100");
  function navigate(){'';//Parent function that redirects
<apex:pageBlock >
 <apex:pageBlockSection columns="1" id="Test" >
  <apex:inputcheckbox value="{!test.istest__c}" label="Same as Above">
    <apex:actionSupport event="onchange" rerender="Test" />
<apex:outputPanel rendered="{!NOT(test.istest__c)}"> 
<apex:inputField value="{!test.Campaign__c}" />
<apex:inputField value="{!test.cust_vendor__c}" />

Note that navigate function we will call from the child window and that would navigate parent frame

<apex:page >
 <!-- Begin Default Content REMOVE THIS -->
 This is your new Page


 function test(){
     window.opener.navigate();//call the parent function from child window and that does the trick

  <apex:form >
 <!-- End Default Content REMOVE THIS -->
  <apex:commandButton onclick="test()" value="Test"/>
The child window script will call the opener  window script and that in turn will redirect the parent frame .

Hope this trick will be useful .

Sunday, 20 July 2014

Won Summer Hackathon Bangalore Contest

So here is the good news .Last night we were declared winner of Summer Hackathon Challenge conducted in my city (Bangalore).To know more you can visit the link.First of all let me very clear that I am nothing without my team .It was complete Team work right from Idea to Implementation .

Let me take some time to Introduce you to my fellow colleagues who have worked and taught me so much and I am just a small part .

+MUKUL goel +rashmi t  

Mukul  you can contact him with email  

Rashmi  you can contact her with email

I have never been to Hackathon before and this was really something I thought i should give a try .Nervous I was but when we formed a Team and Started Building ,Confidence level Picked up.

Thanks to Salesforce and BeMyApp .They had organised the event very well .All that we needed to concentrate was to have a working demo of our application on final day of submission.

First Day -When so many Ideas emerge its important to be a good listener .Appreciating each others Idea In a Team certainly helps and its important to keep the team bonding.We stayed whole night in Mukul room and we had pretty much designed UI flows and we were clear on what needs to be done.Its important to have a rough Idea of how you want to shape your Idea and Design and then build .We had completed I would say 25% on day one and all set for second day.

Is sleep Essential?

Yes as humans its important to relax our minds and keep calm .All thanks to my friend mukul who allowed us to take nap for 4 to 5 hours to relax and rest in his personal room.Salesforce allowed to bring sleeping baggage and we could have slept in hall but never wanted to disturb other coders.

Second Day-I saw we were getting exhausted but we kept going .We kept coding and nearly we did our first git commit  in noon .We knew we are close and all we need to do is to keep focused and achieve as many functionality as we want .Our app build was almost there by 10PM on second day .We decided to take rest .

Thanks to mukul ,he did all data clean up and Data search and kept going till 4 AM(Almost third day morning).I was sleeping but mukul kept going

Third Day-It was the most critical day and we did not wanted to loose our focus and all hardwork we had done in these days .I took initiative to come early and do some git commits as I wanted my team to relax and come refreshed.We knew by after noon we need to complete all coding and do final push.

We knew we had shaped our app well ,even if you have small glitches its not worth to keep concentrating as you have small build time and judges know you are human.

So finally we practiced our presentation and we were all set to go to stage and communicate to judges effectively of what our vision and what we have done .

Experience has been amazing and remember attending these hacks broaden and sharpen your skills and give you an edge on where you stand on overall crowd .So you have nothing to loose .

Winning was not motive its to keep focused and do your best and rest may happen magically.

Our App video is here in the below link and we are so excited about this Sales Booster App to take to next level . 

Thursday, 12 June 2014

Fun with maps in apex-Part 2

This is an extension of my previous blog on Fun with Maps .So from years of coding now on apex we realize we do lot of repetitive  coding ,The code statements keep repeating but objects ,fields and org keep changing .

So here my problem statement was ,I was using the logic of forming a Map of ParentId and List of Child Records frequently for different triggers and different visualforce classes .Something like below as mentioned in the previous blog.

Here is the sample code that kept on repeating for me
The Object kept on changing for various triggers and classes in my org but the basic logic remained same of forming a collection of Map<Id,List<Sobject>>

Repeating code is never a good pattern and felt need to write an utility that can take care of this .Here is my utility class that can be used ti generalize the concept of collecting parentId and the list of child records (List<childrecord>)

The advantage of this pattern is we dont have to code this logic again and again .It accepts the string of the ParentId Field and also List<sobject> .

Lets see simple use cases of this Utility

1)Usage in Trigger
2)Usage to typecast this class into necessary map

Following illustrates how easy it is to generalize this concept and just write once and avoid repetitive usage on all objects .

Thanks and hopefully you enjoyed this post .Looking forward for your comments and feedback .

Saturday, 10 May 2014 Certified Technical Architect - Multiple Choice exam

First of all really sorry for not being active on my blog for quite some time and you will find the reason behind the same was my schedule was hectic and I also decided its right time for me to attend Certified Technical Architect - Multiple Choice exam.

I am glad that i cleared this exam today and thought of sharing some learning's here :)

Its been almost three years on platform and I was involved in wide variety of work ,mostly now on Integration's and Data Migration  Salesforce Projects .So I thought its right time for me to start preparing for at least multiple choice exams as I had confidently submitted the Self Evaluation  and I was informed I am good to go for Next Round .

Again Please don't mail and ask me for dumps as this is against my ethics .Having said that I would definitely provide some insights on what topics one must primarily concentrate while preparing for this Exam .

The Study guide can be obtained from the Certification Website .Now what topics one must concentrate to prepare for this exam.

This exam basically tests your experience on platform ,than anything else so nothing can beat the real experience here .If you have worked on Oauth 2.0,SOAP API's,REST API's,Custom Apex Services ,Network layer Security you should definitely be all good to handle this exam.

The Primary materials I would recommend are below

The above URL will almost give you all the materials and these materials are very good and I read all one by one .They have also arranged it topic wise 

One of my favorite whitepaper is Integration Design Pattern.I downloaded from below URL

The Important topics that i felt were as below

1)Integration Design Pattern(Lot of questions on this topic and you will need to be crystal clear on each approach with pros and cons)

2)Oauth 2.0 and various different types of oauth flows thats possible

Become familiar  with advantages and disadvantages of each one of those flows that patt has documented

3)Federated and Delegated Authentication

4)Advanced Currency Management

There were few questions on this too .make sure you understand multicurrency and related reporting

5)LDV(Large Data Volume Handling)

6)Sharing Architecture

7)Security Coding Guideline's for Visualforce (Know stuff like XSS and CSRF)

8)Network layer concepts like Firewall,Proxy ,Reverse Proxy ,DMZ

9)Apex Design Patterns 

10)Mobile Application Development Apporach(Design Approach ,when to choose hybrid,Native or Salesforce 1)

11)Understand Governance and Change Management Strategy .Understand Importance of

12)Order of execution of validation rules,triggers ,workflows in a context

13)Optimizing your queries .Search on Youtube you will get number of dreamforce sessions

14)Data loading using BULK API ,increasing throughput and Parallelism .

Hope this article you found helpful and all the best if you are attempting this exam :)

Monday, 28 April 2014

Opportunity_hd Not Found Error

Have a look at above screenshot and it says Opportunity_hd not found while deployment .

The cause of this issue is due to Opportunity History Trending Not Enabled in the Destination Instance .This is a weird error and I am posting so that this may help all who encounter this to resolve themselves 

Business Process and Support Process In Changesets Salesforce

The BusinessProcess metadata type enables you to display different picklist values for users based on their profile. It extends the Metadata metadata type and inherits its fullName field.
Multiple business processes allow you to track separate sales, support, and lead life cycles. A sales, support, lead, or solution process is assigned to a record type. The record type determines the user profiles that are associated with the business process. For more information, see “ Managing Multiple Business Processes ” in the Salesforce online help.

So now the query is how to deploy this Business Process and Support process Via the changesets in SFDC?
If you see the component list you wont see the BusinessProcess in components to Add to the changeset.This is pretty weird as the metadata API for same is exposed in Salesforce .
Mnaually creating hundreds of process in each Instance can be time consuming and Tedious and Using Eclipse or Ant for this for an admin or Business analyst can be a huge exercise and error prone .

So again the same question how to Add these BusinessProcess In Changeset?
The answer is simple .We all have Add Dependency Button in changeset build
Here we will discover we have BusinessProcess to Select and Add to the Changeset.Its little weird that it does not appear as Parent Component during change set build .
May the force be with you All :)

Sunday, 16 March 2014

Getting Information of logged In Users Community using apex

Salesforce communities allows you to connect your partners,employees and customers directly to the business process.

Salesforce communities Improve customer service and reduce support costs with Communities 

for Service.

Through this blog post my simple aim to is throw light on apex classes that are available to fetch information about logged in User community.

So lets have a look on how to approach the code to find community-Id and then use the community ID to get information about the users community and user detail

So lets explore the above code and find what all details one can infer from this code
CommunityHelper.getCommunityInfo().urlPathPrefix  ---This is sample on how you can use to get urlPathPrefix and this can be effective in using for various URL navigations .

The above link is really handy to figure what all info one can obtain from getCommunityInfo() class .

The return will be of class and this class has following variables in below image

Hope this blog was helpful and looking to blog more on how to use connectAPI more for chatter apps using vf framework .

Tuesday, 28 January 2014

Parsing An XML Data With DOM Parser In Apex

Parsing the XML data in Apex is always pain and there are already very good blogs and links that really help us to design the strategy for parsing XML data of various complexities .

The above blog from Abhinav one of our MVP of sfdc dev commmunity is informational and i suggest everyone to read this on how to use fast XML DOM.

There is a cookbook article as well on how to effectively achieve the parsing of XML using DOM parsers

One has to know two system classes a)Document Class b)XMLNode Class

Now the question then ,why I am I writing this blog when already there are so much information on web as how to do it.The reason is even after reading all the documents in net ,i struggled to parse an XML as none of the blogs speak on how to parse when we have namespace in the XML.

Here is the sample XML data that i am trying to parse
Now one thing you will observe in the below parser code that i have written ,how i use the namespaces to parse the data.Providing namespace as null will trigger null pointer exceptions

So the idea of this blogpost was just to make one aware on how to parse the XML if there are namespaces .

Hope you enjoyed the blog series .

Sunday, 26 January 2014

Encrypting the XML response from External System In Custom Field Using AES 256 Algorithm

Encrypting the data via crypto classes in apex language is fun and below are the few articles links on developer force that really help us understand better.

Having read the above document one can easily be of opinion thats its too easy with few lines of code to encrypt data using AES 256 and also same can be stored in a field via an apex trigger .It is not so simple when it comes to storing this data into the custom field .

From the above code ,the problem arises when we start thinking on how to store the encrypted  blob data into the field of object .We dont have any field of data type blob in sfdc and thats were my problem  began and hence this blog for people looking for solution around how to store the blog in a Long Text Field and then how to decrypt the same .

The above code will trigger an exception as below

So now the question ,how will i be able to store the encrypted data in string format from the BLOB ?

There are couple of ways to do this ,but shortest ,the best

1)Convert BLOB data to HEX and store in field and then convert HEX back to string.There is lack of methods to do this till date but comming spring 14 release has a new method and much needed for these kind of problem.Once my org will be up with spring 14 i will try this method

Blob blobValue = EncodingUtil.convertFromHex('4A4B4C');

System.assertEquals('JKL', blobValue.toString());

Intresting but its coming in next release

2)Store the data inform of base64Encoded String and later use this and decode and then decrypt

The above code compiles and now lets decrypt and retrieve the original data

The below diagram summarizes the process


Sunday, 5 January 2014


*********** MAXIMUM DEBUG LOG SIZE REACHED ***********

Many Times i get frustrated when i want to log something and see the values in debug log and when i encounter an error saying MAXIMUM DEBUG LOG SIZE REACHED.

We all know the log levels in SFDC can be configured and hence setting filters as below in debug logs help to solve the problem

  • Database : NONE
  • Workflow : NONE
  • Validation : NONE
  • Callouts : NONE
  • Apex Code : ERROR
  • Apex Profiling : NONE
  • Visualforce : NONE

The above stackexchange link helps to identify how to solve the problems .

But when it comes to the TEST classes sometimes when there are too many test methods even filtering as shown above does not help much .How do we solve the problem then ?

One solution is to comment out all other test methods except the method that's giving trouble or suspected of cause of error .Hence we will be able to display logs for only the method and debug the result .

Introducing Lightning Base Components

Lightning Base Components are great addition to the platform and in fact revolutionary .One of the concerns around lightning component ...