Month: December 2016

How to check Person Account are enabled using Apex?

Some time it is needed to check whether this org has person account enabled or not. There are couple of ways we can think of, Using Describe Call

– Describe Call count against Governor limits. Accessing field of Account (“isPersonAccount”)

In this method exception getting generated if that field doesn’t Exist.

Efficiently generate Set from List

Let’s check with some examples, Using Map

In second line we are creating new Map<Id,Sobject> from the results of first line, and then taking the keys from this map. Once this done, heap space is released for this map, and so it is one of the efficient method. One Liner (Without Dynamic SOQL)


Inner Query in Query Locator Bad Practice

Recently came across one code which had inner query in QueryLocator. For example some one has put that in Start method of Batch apex. To give exact example of Query in Start Method of Batch,

I think this is not the right way of doing query. To get into the reason why, i think […]

How to get KeyPrefix of sObject in Salesforce

Every record in Salesforce has an ID which is used to uniquely identify the record. Each ID value is globally unique. The first three digits represent the object type. For example, the Account object uses the 001 prefix; the Note object uses the 002 prefix, Contact uses 003, Users 005, Opportunity 006 etc. We can […]

Dynamic Styling in Visualforce Page

This post is about how dynamically you can display the colour of the field on Visual force page. Here is the example below which will showcase all the opportunities in red which are of amount < 100000 and rest would be in Green. You can find the live demo here.