Tuesday, 25 July 2017

Success Story of :- Gaurav Kheterpal

Welcome to my 11th Salesforce Success Story series. This series is focused on success story and to inspire/encourage new user/Developer. And why we should join our local Salesforce Developer/User group.



1) Your Job Title

Vice President - Mobility & Technology Evangelism at Metacube 

2) Your success Story

I'm a BITS Pilani alumni and I've been in the industry for about 17 years. I used to work on telecom applications and protocol stacks before I accidentally stared my Salesforce journey in 2007. I was initially involved in building mobile applications on the Force.com platform which helped me gain a holistic understanding of Salesforce over the years. I'm a naturally inquisitive person so I tend to dig deeper into how things work and this helped me learn Salesforce. In 2012, my team built an app called ‘Noteprise’ – a connector  between Salesforce and Evernote, basically notes for enterprise powered by the Force.com platform. The app was a runner-up in a global mobile development challenge held by Salesforce and was selected for the mobile dev gallery – a collection of some of the best reference applications. I was then developed a few more interesting applications like one called Socialforce, which is a mashup of Salesforce, Facebook, Twitter and Linkedin & again won an award from Salesforce. I keep experimenting, and in 2014, I wrote another app using the Titanium framework for Force.com which won the Appcelerator enterprise app challenge

Although I started off in 2007, I believe 2012 was the definitive year for me - my app won an award from Salesforce, I presented at Dreamforce for the first time and since then I've not looked back. I've presented sessions at Dreamforce every year since then and I'm eagerly looking forward to the results of Call for papers for Dreamforce 2017 that's due soon.

I'm the co-leader for the Jaipur Developer User Group and we try to do events with high-quality content on a regular basis. I feel honoured that Salesforce recognised me as a developer success story on their blog in year 2015. I was inducted as a Salesforce MVP last year and I believe it's an important milestone in my journey.



3) Why we Should Join a Salesforce User/Developer Group 
There's no better way to learn than learning in a group. Jaipur Developer User Group is a great example of collaborative learning. You get to learn from the others as well as share your knowledge among others. It helps you connect to people and also opens up opportunities to grow your network.
4) Advice for new Salesforce Developer 
Spend time focusing on the concepts. Trailhead is a great starting point. Once you feel confident, appear for the relevant certification to you. Give yourself time - don't look for shortcuts. Salesforce isn't a magic wand for your career but if you work hard, it can help you create the magic.
5) Trailhead badges
I'm at about 90 badges right now and I'm eager to find time to join the elusive Ranger club of 100+ badges. When Trailhead started off, I was among the leaders for the first few weeks but then I just couldn't devote enough time as expected. Hopefully, I'll cross that bridge some day.



Follow Gaurav Kheterpal on:
 Twitter or his blog blog



If you want to share your Salesforce Success Story, Please feel free to drop me an email :- amit.salesforce21@gmail.com 


<<PREVIOUS       NEXT>>


Thanks
Amit Chaudhary
@amit_sfdc


Tuesday, 18 July 2017

How to write test class for Scheduler /Schedulable class in Salesforce



Sample Batch job

global class AccountUpdateBatchJob implements Database.Batchable<sObject> 
{    
    global Database.QueryLocator start(Database.BatchableContext BC)     {
        String query = 'SELECT Id,Name FROM Account';                
        return Database.getQueryLocator(query);     
    }    
    global void execute(Database.BatchableContext BC, List<Account> scope)     {        
        for(Account a : scope)        
        {            
            a.Name = a.Name + 'Updated by Batch job';        
        }        
        update scope;       
    }    
    global void finish(Database.BatchableContext BC) {    }
}



Scheduler Class For Batch Apex


global class AccountUpdateBatchJobscheduled implements Schedulable 
{
    global void execute(SchedulableContext sc) 
    {
        AccountUpdateBatchJob b = new AccountUpdateBatchJob(); 
        database.executebatch(b);
    }
}




Test Class for Scheduler Class


@isTest
private class AccountUpdateBatchJobscheduledTest
{

    static testmethod void schedulerTest() 
    {
        String CRON_EXP = '0 0 0 15 3 ? *';
        
        // Create your test data
        Account acc = new Account();
        acc.name= 'test';
        insert acc;
        
        Test.startTest();

            String jobId = System.schedule('ScheduleApexClassTest',  CRON_EXP, new AccountUpdateBatchJobscheduled());
            CronTrigger ct = [SELECT Id, CronExpression, TimesTriggered, NextFireTime FROM CronTrigger WHERE id = :jobId];
            System.assertEquals(CRON_EXP, ct.CronExpression);
            System.assertEquals(0, ct.TimesTriggered);

        Test.stopTest();
        // Add assert here to validate result
    }
}



Please check below post for Batch job
1) http://amitsalesforce.blogspot.com/2016/02/batch-apex-in-salesforce-test-class-for.html



Please check below post for more detail
1) https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_scheduler.htm


Thanks,
Amit Chaudhary