Nov 10

salesforce To Salesforce Integration Through Apex

    public class salesforceToSalesforceIntegrationThroughApex {

        public void integrateS2S()
            final String LOGIN_DOMAIN = 'login'; //other options: test, prerellogin.pre
            final String USERNAME  = 'user name';
            final String PASSWORD  = 'user password';
            String SERVER_URL;
            String SESSION_ID;

            // How to generate Consumer Key and Consumer Secret Code? 

            //Goto Setup > Build > Apps>Connected Apps>New> Enter required data alog with API (Enable OAuth Settings)
            String Consumer_Key = '3MVG9Y6d_Btp4xp7HI0OKNu0NNZ7CbuDa8ISx.u_E6f4e3Q.4MBRzkD3Mi3lzUCwlC3OgO5g5oT.I7xVYt1aB';
            String Consumer_Secret = '766475509074793020';
            HttpRequest request = new HttpRequest();
            request.setHeader('Content-Type', 'application/x-www-form-urlencoded');
            request.setHeader('SOAPAction', '""');
            String reqbody = 'grant_type=password&client_id='+Consumer_Key+'&client_secret='+Consumer_Secret+'&username='+USERNAME+'&password='+PASSWORD;          
            Http hp = new Http();
            HttpResponse response = hp.send(request);
            JSONParser parser = JSON.createParser(response.getbody());
            OAuth2 objAuthenticationInfo = (OAuth2)JSON.deserialize(response.getbody(), OAuth2.class);         
                    SESSION_ID = objAuthenticationInfo.access_token;
            final PageReference theUrl = new PageReference(SERVER_URL + '/services/data/v22.0/query/');
            theUrl.getParameters().put('q','select id,name from Account limit 10');
            request = new HttpRequest();
            request.setHeader('Authorization', 'OAuth ' + SESSION_ID);
            String body = (new Http()).send(request).getBody();
            System.debug('Accounts in JSON format: ' + body);
            JSONParser parser2 = JSON.createParser(body);
                }while(parser2.hasCurrentToken() && !'records'.equals(parser2.getCurrentName()));
                    final List<Account> accounts = (List<Account>) parser2.readValueAs(List<Account>.class);
                    System.debug('Accounts as native list: ' + accounts);                    


Mar 04

Data Management

Data Management

Data Management is used for to

  1. Export the data from SF Objects to CSV Files by DM Wizards.

  2. Import data from CSV files to SF Objects by DM Wizards.

    1. For What are the objects we can import data from CSV Files.

      1. Custom objects

      2. Solutions, Leads, Accounts/ Contacts

      3. we can store analytical snap shots (by mapping the custom object to the reports storing the reports is called analyticalsnapshot.)

  3. Mass Transfer records, deletion, update address and Approval Request.

  4. Updating State and Country pick list.

  5. We can examine Storage Limits or usage.

  6. Data Loader (Through Command line interpreter we can connect to SF and we can export and import with sale forces) from Desk Top.

Data Export

  1. Export now

  2. we can schedule Export

  3. with in 48hrs the link will be generated though which we can download the csv files.

Data Loder

How to login the Dataloder : Download Data loder form your SF Account >DataManagment > Data Loder 

User Id : your user id

Password : YourPasswordSecurityTocken

  1. Bulk export and import

  2. Insert, Update, Upsert, delete, Hard delete

  3. we can use data loader in tow way 1st User Interface , 2ed. Command line

  4. Support for large files with up to 5 million records where as DM Wizard 50000/- (because it is through browser)

  5. You need to load into an object that is not yet supported by the import wizards

  6. You want to schedule regular data loads, such as nightly imports.

  7. You need to load 50,000 to 5,000,000 records. Data Loader is supported for loads of up to 5 million records. If you need to load more than 5 million records, we recommend you work with a partner or visit the App Exchange for a suitable partner product.


Use the import wizards when:

You are loading less than 50,000 records.

The object you need to import is supported by import wizards. To see what import wizards are available and thus what objects they support, from Setup, click Data Management.

You want to prevent duplicates by uploading records according to account name and site, contact email address, or lead email address.

Feb 19

How to use INCLUDES function in Salesforce??

     Salesforce having lot of functions one among them is INCLUDES, it is a Text Function. I observed saleforce Help document also not providing detailed usage of this function. INCLUDES returns Boolean value if the provided single selected value is correct.

Exp: i.e if multipicklist Favorite_Animal__c selected value are (Dog,Cow,Horse)

then a valid INCLUDE function looks like this INCLUDES(Favorite__Animal__c,'Dog');

it will not accept INCLUDES(Favorite__Animal__c,'Dog; Cow; Horse') kind of functions. even it will not accept

INCLUDES(Favorite__Animal__c,'Dog' and 'Cow' and 'Horse') kind of functions.

So INCLUDES is not for check multiple selected values, it is only for to check whether given value is exist or not.

Then what is the use of multypicklist INCLUDE function?

To ensure multiple selected items we should use AND Logical function as follows. AND(INCLUDES(Favorite__Animal__c,'Dog'),INCLUDES(Favorite__Animal__c,'Cow'),INCLUDES(Favorite__Animal__c,'Horse'))

Nov 09

How Search Works in Salesforce?

Search uses custom algorithms that consider:

  • Your search terms
  • Ignored words in search terms (for example, “the,” “to,” and “for”)
  • Search term stems (for example, searching for speaking returns items with speak)
  • Proximity of search terms in a record
  • Record ownership
  • Most recently accessed records

You might not have the same search results as another user performing the same search because searches are configured for the user performing the search. For example, if you recently viewed a record, the record relevancy increases and the record moves higher in your search results list. Records you own also move higher in your search results.

How your search works depends on whether you're using SidebarAdvanced, or Global Search.

May 01

Training Syllabus For Adv Developer 501 Certification

-- Download Training Syllabus For Adv Developer 501 Certification as PDF --

Development Lifecycle



List and describe the key features, tools, and technologies of application lifecycle management and development

Describe best practices for managing multi-team and multi-project development initiatives with and describe how to use these best practices

List and describe the various development and test environments available on the platform

Describe how to manage sandbox environments

Given a scenario, determine whether to use package or metadata deployment

Describe how to use the migration tool

Describe the capabilities and constraints of metadata text files for manipulating application metadata

Describe the requirements and processes for deploying changes to an application using a metadata tool Code (Apex)


List and describe the features of code and distinguish between it and other programming languages

Describe when and why to use code

List and describe syntax features of code

Describe the ways code can be invoked

Describe use cases for code in an integration scenario

Describe how to send and receive email via code

Describe use cases for dynamic code

Describe use cases for batch code

Describe the save execution order and use of before and after triggers

Describe the types of governor limits and contexts and the rationale behind them

Describe how to write scalable code that handles bulk operations Pages (Visualforce)



Describe the benefits, functions, and features of pages and how it conforms to the model-view-controller pattern

Describe how to incorporate pages into applications

Describe how to create data, action, and component binding expressions

List and describe syntax features of pages

Describe best practices for incorporating static resources, style sheets, and other content into pages

Describe how to create and use a page as the template for multiple pages

Describe how to handle client-side behavior through the use of either standard components or custom JavaScript

Describe and incorporate proper error-handling techniques

Describe how to create a custom component and the benefits of custom components versus other techniques for code reuse

Describe how to leverage PDF generation

Distinguish between standard controllers, custom controllers, and extensions

Describe the request lifecycle of a page

Describe viewstate and the stateful programming model of pages

Describe the benefits of using code classes as structs or wrappers of sObjects


Testing and Debugging


Describe the techniques and tools available to debug, test, and monitor code execution

List and describe the contents and use of the System Log

Describe how to create and run unit tests as well as techniques for achieving 100% test coverage

Describe how to test page controllers

Describe how to test email send and receive in different environments


Feb 03

Salesforce Apex enum Example

crate a class season,month,MyExample bellow like this
public enum Season {

public enum Month {

public class MyExample {
public List seasonMonths(Season s)

List listMonths = new List();


else if(s==season.SPRING)

else if(s==season.SUMMER)
else if(s==season.FALL)

return listMonths;
Steps to execute this code

MyExample obj = new MyExample();

Jan 21

SOQL Select all fields (Select * from )

public class ApexSelectQueries {
//SOQL will not support direct select * from syntax, so we need to retrive all field names first then we should construct a select statment with the fields.
//This method generates a SOQL select statement equal to select * from object.
//if your object is Account then your fieldMap should be return type of this statment schema.SObjectType.Account.fields.getMap();
//The return type of this method is string i.e select field1,field2,… from yourObject.
public String selectAll(Map fieldMap,String yourObject)
Map fldObjMap = fieldMap;
List fldObjMapValues = fldObjMap.values();
String theQuery=”;
for(Schema.SObjectField sObjField : fldObjMapValues)
String theName = sObjField.getDescribe().getName();
theQuery += theName+’,';
theQuery = theQuery.removeEnd(‘,’);
theQuery = ‘SELECT ‘+theQuery+’ From ‘+yourObject;
return theQuery.trim();

Dec 26

Sharing Rules

Sharing rules allow you to selectively grant data access to defined sets of users. Review the following notes before using sharing rules:

  • You can use sharing rules to grant wider access to data. You cannot restrict access below your organization-wide default levels.
  • Sharing rules apply to all new and existing records that meet the definition of the source data set.
  • Sharing rules apply to both active and inactive users.
  • When you change the access levels for a sharing rule, all existing records are automatically updated to reflect the new access levels.
  • When you delete a sharing rule, the sharing access created by that rule is automatically removed.
  • When you transfer records from one user to another, the sharing rules are reevaluated to add or remove access to the transferred records as necessary.
  • When you modify which users are in a group, role, or territory, the sharing rules are reevaluated to add or remove access as necessary.
  • Sharing rules automatically grant additional access to related records. For example, opportunity sharing rules give role or group members access to the account associated with the shared opportunity if they do not already have it. Likewise, contact and case sharing rules provide the role or group members with access to the associated account as well.
  • If multiple sharing rules give a user different levels of access to a record, the user gets the most permissive access level.
  • Users in the role hierarchy are automatically granted the same access that users below them in the hierarchy have from a sharing rule, provided that the object is a standard object or the Grant Access Using Hierarchies option is selected.
  • Regardless of sharing rules, users can, at a minimum, view the accounts in their territories. Also, users can be granted access to view and edit the contacts, opportunities, and cases associated with their territories' accounts.
  • Making changes to sharing rules may require changing a large number of records at once. To process these changes efficiently, your request may be queued and you may receive an email notification when the process has completed.
  • You can create rules to share records between most types of Customer Portal users and Salesforce users. Similarly, you can create sharing rules between Customer Portal users from different accounts as long as they have the Customer Portal Manager user license. However, you can't include high-volume portal users in sharing rules because they don't have roles and can't be in public groups.
  • You can easily convert sharing rules that include Roles, Internal and Portal Subordinates to include Roles and Internal Subordinates instead by using the Convert Portal User Access wizard. Furthermore, you can use this wizard to convert any publicly accessible report, dashboard, and document folders to folders that are accessible by all users except for portal users.
  • Lead sharing rules do not automatically grant access to lead information after leads are converted into account, contact, and opportunity records.