Friday, March 15, 2013

Data Loader : each batch has its own limit

I have some information related to Apex Data loader. In recent days I was trying to upload huge amount of data to Salesforce instance using Data Loader. It was updating nearly 17000 records which in turn will fire an update trigger . The trigger contains say 3 SOQL statement.

Here Apex data Loader can be set with  batch size say, 50. So data will be updated as well as trigger will be fired for each 50 records.

The information here is that :


In Data loader , each batch is a discrete operation/transaction.Governor limits apply to each batch/operation rather than to the whole upload.
Each batch has its own limits and each batch consumes an API call, they are unrelated to one another.
Reduce the batch size if you hit governor limits, this will of course increase the time it takes to process them.

Here is detail which may help:
http://limitexception.herod.net/2011/12/15/talend-vs-apex-dataloader-bulk-uploaddownload-benchmarks/ 

Thursday, March 7, 2013

Create User record in Test Method in Salesforce Apex

Salesforce.com is working on providing developers with a better testing environment. Salesforce.com requires you to write test cases to deploy code to production.You’ll need to create all of your test records and test each scenario to ensure your code performs as expected.
Here’s a small test class for Creating User record.


@isTest
private class Test_CreateUser{

Profile pfl = [select id from profile where name='Standard User'];
User testUser = new User(alias = 'db', email='deepabalib@mfs.com',
            emailencodingkey='UTF-8', lastname='Testing', languagelocalekey='en_US',
            localesidkey='en_US', profileid = pfl.Id,  country='United States',
            CommunityNickname = 'u1',timezonesidkey='America/Los_Angeles',
            username='deepabali@mindfiresolutions.com');
insert  testUser;

}