Test class for Batch Apex in Salesforce

When testing your batch Apex, you can test only one execution of the execute method. You can use the scope parameter of the executeBatch method to limit the number of records passed into the execute method to ensure that you aren't running into governor limits.

The executeBatch method starts an asynchronous process. This means that when you test batch Apex, you must make certain that the batch job is finished before testing against the results. Use the Test methods startTest and stopTest around the executeBatch method to ensure it finishes before continuing your test. All asynchronous calls made after the startTest method are collected by the system. When stopTest is executed, all asynchronous processes are run synchronously. If you don’t include the executeBatch method within the startTest and stopTest methods, the batch job executes at the end of your test method for Apex saved using Salesforce.com API version 25.0 and later, but not in earlier versions.

Starting with Apex saved using Salesforce.com API version 22.0, exceptions that occur during the execution of a batch Apex job that is invoked by a test method are now passed to the calling test method, and as a result, causes the test method to fail. If you want to handle exceptions in the test method, enclose the code in try and catch statements. You must place the catch block after the stopTest method. Note however that with Apex saved using Salesforce.com API version 21.0 and earlier, such exceptions don't get passed to the test method and don't cause test methods to fail.

Sample Test Class:

public class SampleTest {
public static testMethod void testBatch() {
Batch_Class_Name obj = new Batch_Class_Name();
ID batchprocessid = Database.executeBatch(obj );


Formula Expression is required on the action attributes error

Formula Expression is required on the action attributes error occurs when pagereference('/apex/pageName') doesn't have backslash in front of apex.

Correct: pagereference('/apex/sample1');

Incorrect: pagereference('apex/sample1');

in incorrect, backslash ('/') is missing in front of apex.


apex:actionFunction is not calling Apex method - Work around

Sometimes, apex:actionFunction is not calling Apex method. The Work around for this is, the Javascript function should return true or false. In apex:commandButton, before calling the Javascript function, we should add return. If the Javascript function returns true, then the method will be invoked else it will not invoke the Apex method.


Visualforce page:

<apex:page sidebar="false" Controller="Sample" showHeader="true">
<apex:form >
    <apex:commandButton value="show" onClick="return confirmReq();" action="{!show}"/>
<apex:outputPanel id="jspanel">
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
        function confirmReq() {
        if(condition) {
            return true;    
        } else {
            return false;                                


public class Sample {     
    public sample() {
    public void show() {

in the above example, show() from Apex will not be executed until the Javascript function returns true.


How to apply auto number for existing records in Salesforce?

Check "Generate Auto Numbers for existing records" check box while creating auto number field.

It will take some time to reflect after creating the field.


How to display Parent, Child and Grandchild records in pageBlockTable in Salesforce?

Objects: Member, Interest, Equipment

Parent : Member
Member's Child : Interest
Member's Grandchild and Interest's Child : Equipment

Visualforce page:

<apex:page sidebar="false" Controller="Sample" showHeader="true">
<apex:form >
<apex:pageBlock >
    <apex:pageBlockTable value="{!memberWrapperList}" var="W">
        <apex:column value="{!W.member.Name}"/>
        <apex:column value="{!W.member.Age__c}"/>
        <apex:column >
            <apex:pageblockTable value="{!W.intrstList}" var="I">
                <apex:column value="{!I.Name}"/>
                <apex:column >
                    <apex:pageBlockTable value="{!I.Equipments__r}" var="E">
                        <apex:column value="{!E.Name}"/>
                        <apex:column value="{!E.Serial_Number__c}"/>

Apex Controller:

public class Sample { 
    public List<Member__c> memberList { get; set; }
    public List<Interest__c> interestList { get; set; }
    public Map<Id, List<Interest__c>> memIdInterestListMap { get; set; }
    Set<Id> memberIds = new Set<Id>();
    Map<Id, Member__c> memberMap = new Map<Id, Member__c>();
    public List<MemberWrapper> memberWrapperList { get; set; }

    public Sample() {   
        memberList = [SELECT Age__c, Name FROM Member__c];
        memIdInterestListMap = new Map<Id, List<Interest__c>>();
        memberWrapperList = new List<MemberWrapper>();
        if(memberList.size() > 0) {
            for(Member__c mem : memberList) {
                memberMap.put(mem.Id, mem);
            interestList = [SELECT Name, Member__c, (SELECT Name, Serial_Number__c FROM Equipments__r) FROM Interest__c WHERE Member__c IN : memberIds];
            system.debug('Interest List is ' + interestList);
        if(interestList.size() > 0) {
            for(Interest__c intrst : interestList) {
                    memIdInterestListMap.put(intrst.Member__c, new List<Interest__c>());
            for(Id interestId : memIdInterestListMap.keySet()) {
                memberWrapperList.add(new MemberWrapper(memberMap.get(interestId), memIdInterestListMap.get(interestId)));
    public class MemberWrapper {
        public Member__c member { get; set; }
        public List<Interest__c> intrstList { get; set; }
        public MemberWrapper(Member__c member, List<Interest__c> intrstList) {
            this.member = member;
            this.intrstList = intrstList;


How to get parent's parent id using jQuery?

Sample Code:


THE HINDU - HITACHI Scholarships

If you are interested in going to Japan, make use of THE HINDU - HITACHI Scholarships.

Check the below link for more info



System.LimitException: Too many DML rows: 10001

System.LimitException: Too many DML rows: 10001 error occurs, when we try to do DML operations to more than 10000 records at a time.

If we want to do DML operations to more than 10000 records at a time, we have to call a batch class from the current class to handle it separately.


How to sort null values at last in SOQL?

Generally in SOQL, null values are sorted first. In order to sort null values at last make use of NULLS LAST keyword.



How to Sort both in Ascending and Descending order in SOQL?


SELECT Name, CMR_Number__c FROM Account ORDER By Name ASC, AccountSite DESC

Using the above SOQL, accounts will be sorted by Name in ascending order and then by AccountSite in descending order.

How to enable Console Keyboard Shortcuts in Salesforce?

1. Go to Setup --> Build --> Create --> Apps.

2. Open the Console App.

3. Click "Customize keyboard shortcuts" link.

4. Click "Edit".

5. Enable "Keyboard Shortcuts" and click "Save" button.

6. Go to the Console application and click "Show Keyboard Shortcuts".

Salesforce Console for Sales Application

In Winter '14 Release, Salesforce has introduced Console for Sales application.

Salesforce Console for Sales allows users to access Leads, Contacts, Accounts, etc.. very easily and quickly with less number of navigation.

Advantages of Salesforce Console for Sales:

1. Quickly one can get helpful and useful information from Sales intelligence.

2. One can log interaction with the records.

3. We can pin frequently viewing record on the screen for easier access instead of searching it.

4. One can switch over other records using sub tabs instead opening the record in new window or in new tab in the browser.


 Live Agent can’t be enabled in a Salesforce Console for Sales unless Service Cloud is enabled for your organization.

Setup procedure:

1. Contact salesforce.com to have the Salesforce Console for Sales enabled for your organization.

Use the below links to Contact Salesforce.com support




2. Assign the Sales Console User permission set license to a user.

3. Enable the “Sales Console”permission on the permission set.

4. Assign the user to the permission set. Only users with a Sales Console User permission set license can be assigned to permission sets that include the “Sales Console” permission.

5. Create a Salesforce Console app and make it available in the user’s profile.

Incorrect Parameter type for operator '&' error in formula field in Salesforce

This error occur when you are trying to concatenate two fields values into a single formula field or just populating a value from a field in Formula Field which is not returning text.

To avoid this error, use TEXT() method.


TEXT(CreatedDate) & TEXT(Age__c)

here CreatedDate is a Date Field and Age__c is Number Field.

TEXT() method should be used even in case of Picklist Field.


Newly deployed fields missing issue in Salesforce

After deploying the fields and after adding those fields to the page layout, sometimes it will not be available to the users. This is mainly due to Field Level Security.

So, after deploying the fields, we have to deploy the profiles or else we have to set the Field Accessibility.

To check the field accessibility, kindly use the below link


How to find the initial owner of the record in Salesforce?

CreatedBy is used to find the initial owner of the record in Salesforce.

Page Layout Assignment

After defining page layouts, assign which page layouts users see. A user’s profile determines which page layout he or she sees. In addition, if your organization is using record types for a particular tab, the combination of the user’s profile and the record type determine which page layout is displayed.
You can assign page layouts from:
1. The object's customize page layout or record type page
2. The enhanced profile user interface.
3. The original profile user interface

Standard Object:

Custom Object:

Salesforce Success Community

Kindly visit the below link for Salesforce Success Community


In Salesforce Success Community, we can

1. Discuss about our issues we are facing in Salesforce project.

2. Get information about known issues in Salesforce.

3. Improve our knowledge in Salesforce.

4. Get quick solution from experts for our issues in Integration, Development, Administration, Web Services and so on.

5. Gain more knowledge in all aspects of Salesforce.

6. Help others for their issues where we can avoid the same issue when we face the same.

For Development related queries, post it in the below link


Price Waterfall

The price waterfall is a way of describing the progression of prices from published list price to the final price paid by a customer.

The Price Waterfall is at the heart of any pricing organization. It is an effective tool to identify margin leakages and creates visibility from a reference list price down to the pocket margin, including discounts, rebates, and other cost elements. On top of that, the visual representation of your cost allocations makes comparison with your peers very easy.

We have seen that quick wins usually lie in effective pricing execution. Examples of opportunities in this area include raising product/service value perception, introducing price corridors, optimizing product mix and minimizing margin leakages through effective discounting.

By analyzing the price waterfall, marketers can determine where product value is being lost. This can be especially important in businesses that allow the sales channel to reduce prices in order to secure customers. The price waterfall can help focus attention on deciding whether these discounts make sense for the business.

Difference between Salesforce and SAP

Very huge Software
Less weighted Software
Difficult for maintenance
Easy for maintenance
Limits are very less
Limits are very high
Has very complex process
Has very easy process
SAP coding is bulky and inefficient
Salesforce.com coding is easy and efficient
It is not that much user friendly
Very user friendly
Complex in usage
Ease in usage

How to send free SMS using Google SMS?

1. Log in to your Gmail Account.

2. Go to Settings.

3. Go to "Labs" tab.

4. Enable "SMS (text messaging) in Chat" app.

5. Add the Mobile Number to the contact.

6. Search the contact and click "Send SMS" option to send Free SMS.

How to change the password of BSNL wifi router?

To change the password of BSNL wifi router, kindly follow the below steps

1. Go to this link "".

2. Enter the login credentials

Username  : admin
Password   : admin

3. Go to Interface Setup --> Wireless.

4. Pre-Shared key is the WIFI Password. If you want you can change it here and save.