Professional Documents
Culture Documents
Introduction To SalesForce
Introduction To SalesForce
1. Introduction of SalesForce.......................................................................................................................3
1.1 SalesForce CRM:................................................................................................................................3
1.2 Force.com platform...........................................................................................................................3
1.3 AppExchange.....................................................................................................................................3
1.4 Web services......................................................................................................................................3
1.5 Configuration.....................................................................................................................................3
2. Force.com................................................................................................................................................3
3. Web services in SalesForce......................................................................................................................4
3.1 SOAP API............................................................................................................................................4
3.2 REST API.............................................................................................................................................4
3.3 Bulk API..............................................................................................................................................4
3.4 Metadata API.....................................................................................................................................4
3.5 Enterprise WSDL................................................................................................................................4
3.6 Partner WSDL....................................................................................................................................5
4. Apex.........................................................................................................................................................5
5. Visual Force.............................................................................................................................................5
5.1 What is VisualForce?..........................................................................................................................5
5.2 Visualforce Markup...........................................................................................................................5
5.3 Visualforce Controllers......................................................................................................................5
5.4 Where Can A VisualForce Pages Be Used?.........................................................................................6
6. Create your own First Visual Force Page.................................................................................................7
6.1 Add Some Functionality to your Visual Force page............................................................................7
6.2 Examples............................................................................................................................................7
6.2.1 Save the records into custom objects from text box on VF page:...............................................8
6.2.2 Bind the drop-down list on VF page:...........................................................................................9
6.2.3 Load the child Dropdown record on the selection of parent Dropdown record:........................9
6.2.4 Search the records, Show in Data Table and Fill the fields in the textboxes automatically:.....10
6.2.5 Insert or Update the records on one button:............................................................................12
References:................................................................................................................................................14
Documents provided by SalesForce:......................................................................................................14
Tools for Import and Export of data from one data base instance to SalesForce and vice versa:.........14
Workbooks by SalesForce......................................................................................................................14
Data Management videos:....................................................................................................................14
Data Migration: The Apex Data Loader:................................................................................................14
Developer Development Life cycle Force.com:.....................................................................................14
Pick-List Blog..........................................................................................................................................14
Based on pick-list selection, display corresponding page block on VF page:.........................................14
Dynamically add values to pick-list using Visualforce............................................................................14
Apex Code Developer's Guide:..............................................................................................................14
Visualforce Developer's Guide:..............................................................................................................14
Develop the Customize Look up on Visual Force page:.........................................................................14
Some useful Podcasts for Admin, Developer and Advance developer certification:.............................14
Wikipedia of SalesForce:........................................................................................................................14
Force.com for .NET Developers.............................................................................................................14
Force.com Canvas..................................................................................................................................14
Examples of Advanced Formula Fields...................................................................................................14
1. Introduction of SalesForce
Salesforce.com is a global cloud computing company. Though best known for its customer relationship management (CRM)
product, which means it is used to keep track of and strengthen a company’s relationship with its existing and potential clients.
SalesForce also expanded in the following areas:
Must Watch:
Cloud Computing: What is Cloud Computing?
What is SalesForce?
SalesForce Platform Overview & Demo?
1.3 AppExchange
AppExchange is a marketplace for cloud computing Web application built for the Salesforce.com community and delivered by
partners or by third-party developers, which users can purchase and add to their Salesforce.com environment. All
salesforce.com partners can distribute applications and solutions on AppExchange. Applications created on the Force.com
platform are installed by Salesforce.com customers.
1.5 Configuration
SalesForce users can configure their CRM application. In the system, there are tabs such as "Contacts," "Reports," and
"Accounts." Each tab contains associated information. For example, "Contacts" has standard fields like First Name, Last Name
and Email. Configuration can be done on each tab by adding user-defined custom fields
Configuration can also be done at the "platform" level by adding configured applications to a SalesForce instance which is
adding sets of customized / novel tabs for specific vertical- or function-level (Finance, Human Resources, etc.) features.
2. Force.com
Force.com platform to build virtually any kind of app, most apps share certain characteristics such as:
Note: In order for a .NET application to integrate with Force.com, a reference to the SOAP API must be added to the application
within Visual Studio. This reference is established through the use of a WSDL file generated from the Force.com platform. A
WSDL file is an XML file that describes how a SOAP-based web service functions, how an application can communicate with the
web service, and the operations allowed to be conducted within the SOAP API. For complete detail check the following link
Integration with .NET by using WSDL.
4. Apex
Use Apex if you want to:
Create Web services.
Create email services.
Perform complex validation over multiple objects.
Create complex business processes that are not supported by workflow.
Create custom transactional logic (logic that occurs over the entire transaction, not just with a single record or
object.)
Attach custom logic to another operation, such as saving a record, so that it occurs whenever the operation is
executed, regardless of whether it originates in the user interface, a Visual force page, or from SOAP API
5. Visual Force
Developers can use Visualforce to create a Visualforce page definition. A page definition consists of two primary elements:
• Visualforce markup
• A Visualforce controller
• A standard controller consists of the same functionality and logic that is used for a standard Salesforce page. For example, if
you use the standard Accounts controller, clicking a Save button in a Visualforce page results in the same behavior as clicking
Save on a standard Account edit page. If you use a standard controller on a page and the user doesn't have access to the object,
the page will display a insufficient privileges error message. You can avoid this by checking the user's accessibility for an object
and displaying components appropriately.
• A standard list controller enables you to create Visualforce pages that can display or act on a set of records. Examples of
existing Salesforce pages that work with a set of records include list pages, related lists, and mass action pages.
• A custom controller is a class written in Apex that implements all of a page's logic, without leveraging a standard controller.
If you use a custom controller, you can define new navigation elements or behaviors, but you must also reimplement any
functionality that was already provided in a standard controller. Like other Apex classes, custom controllers execute entirely in
system mode, in which the object and field-level permissions of the current user are ignored. You can specify whether a user
can execute methods in a custom controller based on the user's profile.
• A controller extension is a class written in Apex that adds to or overrides behavior in a standard or custom controller.
Extensions allow you to leverage the functionality of another controller while adding your own custom logic.
Because standard controllers execute in user mode, in which the permissions, field-level security, and sharing rules of the
current user are enforced, extending a standard controller allows you to build a Visualforce page that respects user
permissions. Although the extension class executes in system mode, the standard controller executes in user mode. As with
custom controllers, you can specify whether a user can execute methods in a controller extension based on the user's profile.
Note: Although custom controllers and controller extension classes execute in system mode and thereby ignore user
permissions and field-level security, you can choose whether they respect a user's organization-wide defaults, role
hierarchy, and sharing rules by using the with sharing keywords in the class definition. For information, see “Using
the with sharing or without sharing Keywords” in the Force.com Apex Code Developer's Guide.
5.4 Where Can A VisualForce Pages Be Used?
Developers can use VisualForce pages to:
• Override standard buttons, such as the New button for accounts, or the Save button for contacts
• Override tab overview pages, such as the Accounts tab home page
• Define custom tabs
• Embed components in detail page layouts
• Create dashboard components or custom help pages
• Customize, extend, or integrate the sidebars in the Service Cloud console (custom console components)
https://Salesforce_instance/apex/myNewPageName
For example, if you want to create a page called “ForDocument” and your salesforce.com organization uses
na3.salesforce.com, enter http://na3.salesforce.com/apex/ForDocument.
Because the page does not yet exist, you are directed to an intermediary page from which you can create your new page.
Note: If you do not have Visualforce development mode enabled, you can also create a new page from Setup by
clicking Develop > Pages, and then clicking New.
Visualforce pages can always be edited from this part of setup, but to see the results of your edits you have to navigate
to the URL of your page. For that reason, most developers prefer to work with development mode enabled so they
can view and edit pages in a single window.
Note: To read about Visual Force Page Development in Detail follow the Visualforce Developer's Guide
Here in SalesForce already provides the some standard data source in form of standard object like account, contact,
opportunity and many more, but all these are designed for CRM based model so what if we have to develop our own
application:
To develop any customize application by using of Force.com platform we got one data source called custom objects, these
objects are same as table in other database we can create number of fields with different data type. For more information gone
through the tutorial Force.Com Workbook.
6.2 Examples
Now we will take a look on some example which will help you to implement in a custom application:
6.2.1 Save the records into custom objects from text box on VF page:
Step 1: Create the Custom Object (Employee)
1. Login to your SalesForce account
2. Go to Setup-> Create -> Objects and follow the instructions
Step 2: Create one VF page (Already described in previous topic) paste the following code:
VF Code:
<apex:page standardController="Employee__c" extensions="EmployeeDemo" >
<apex:form >
<h1>Congratulations</h1>
This is your new Page: ForDocument
<Apex:pageBlock >
<apex:inputField value="{!objEmployee.Employee_Name__c}"/>
<apex:pageBlockSection >
<apex:commandButton Action="{!Save}" Value="Save" />
</apex:pageBlockSection>
</Apex:pageBlock>
</apex:form>
</apex:page>
Controller:
public with sharing class EmployeeDemo
{
public Employee__c objEmployee {get;set;}
public EmployeeDemo(ApexPages.StandardController controller) //Constructor
{
objEmployee= new Employee__c();
}
public PageReference Save()
{
Try
{
Insert objEmployee;
}
Catch (Exception ex)
{
System.debug('\n\nException ='+ex.getMessage()+'\n\n');
}
PageReference pr = new PageReference('/apex/ForDocument'); // To refresh the page again
pr.setRedirect(true);
return pr;
}
}
Step 3: Debug the log and check record got saved or not
As we are catching any exception in the catch block so you can check the debug log if any error occurred in saving the records.
Below is brief process to check the log.
2. Go to Setup -> Monitor -> Logs -> Debug Logs option -> Create the monitored user
3. If any error comes you can check the log like below:
Step 1: Insert some records in the object employee which we have already created and paste the code below on VF page and in
Controller:
Visual-Force:
Apex-Code:
public with sharing class EmployeeDemo
{
public EmployeeDemo(ApexPages.StandardController controller)
{
objEmployee= new Employee__c();
}
public Employee__c objEmployee {get;set;}
public List<selectOption> getLoadEmployee()
{
List<selectOption> Employees = new List<selectOption>();
Employees.add(new selectOption('None','None'));
for(Employee__c empname : [select ID,Employee_Name__c from Employee__c] )
{
Employees.add(new selectOption(empname.ID,empname.Employee_Name__c));
}
return Employees;
}
}
6.2.3 Load the child Dropdown record on the selection of parent Dropdown record:
Step 1: For this kind of requirement first create the master-child or lookup relation between the objects. Here we have created
look-up relation between Employee and Department objects
Visual-Force:
<apex:page standardController="Employee__c" extensions="EmployeeDemo" >
<apex:form >
<apex:pageblock title="Employee" >
<apex:pageBlockSection title="Department">
<apex:selectList required="true" multiselect="false" label="Departments" size="1" value="{!
DepartmentSelectedvalue}">
<apex:selectOptions value="{!LoadDepartment}"/>
<apex:actionSupport event="onchange" reRender="detailEmployee"/>
</apex:selectList>
</apex:pageBlockSection>
<apex:pageBlockSection title="Employee" id="detailEmployee" >
<apex:selectList required="false" multiselect="false" size="1" label="Employee" style="align:left">
<apex:selectOptions value="{!LoadEmployee}"/>
</apex:selectList>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex-Code:
public with sharing class EmployeeDemo
{
public EmployeeDemo(ApexPages.StandardController controller)
{
objEmployee= new Employee__c();
}
public Employee__c objEmployee {get;set;}
public string DepartmentSelectedvalue {get;set;}
public List<selectOption> getLoadEmployee()
{
List<selectOption> Employees = new List<selectOption>();
Employees.add(new selectOption('None','None'));
for(Employee__c empname : [select ID,Employee_Name__c from Employee__c where Department__c
=:DepartmentSelectedvalue] )
{
Employees.add(new selectOption(empname.ID,empname.Employee_Name__c));
}
return Employees;
}
public list<selectoption> getLoadDepartment()
{
List<selectoption> Departments = new List<selectoption>();
Departments.add(new selectOption('None','None'));
for(Department__c departmentname : [select ID, DepartmentName__c from Department__c] )
{
Departments.Add(new selectoption(departmentname.ID,departmentname.DepartmentName__c));
}
return Departments;
}
}
6.2.4 Search the records, Show in Data Table and Fill the fields in the textboxes automatically:
In this Example we will try to search the record on the basis of input criteria, if records are found those will come in data table
and on the click of one link button (which is in data-table), fields will be filled automatically according to requirement.
Visual-Force:
<apex:page standardController="Employee__c" extensions="EmployeeDemo" >
<apex:form >
<apex:pageblock title="Employee" >
<apex:pageBlockSection title="Employee Lookup">
<apex:inputText id="txtlookup" value="{!inputValue}" />
<br/>
<apex:commandButton value="Look up" action="{!Lookup}"/>
<br/>
<br/>
<apex:dataTable id="dtEmplyeeRecords" value="{!objEmployee}" var="er" width="100%" >
<apex:column value="{!er.Id}" width="33%" headerValue="Employee ID"/>
<apex:column width="33%" headerValue="Employee Name">
<apex:commandLink value="{!er.Employee_Name__c}" >
<apex:param name="testusername" assignTo="{!testuser}"
value="{!er.Employee_Name__c}" />
</apex:commandLink>
</apex:column>
<apex:column value="{!er.Phone_Number__c}" width="33%" HeaderValue="Phone Number" />
</apex:dataTable>
<br/>
<apex:inputText value="{!testuser}" id="txtclickedvalue"/>
</apex:pageBlockSection>
</apex:pageblock>
</apex:form>
</apex:page>
Apex-Code:
public with sharing class EmployeeDemo
{
public EmployeeDemo(ApexPages.StandardController controller)
{}
public List<Employee__c> objEmployee {get;set;}
Public String inputValue {get; set;}
Public String testuser {get; set;}
Public String LikeCondition = '';
public List<Employee__C> gtEmployee()
{
LikeCondition = '%' + inputValue + '%' ;
objEmployee = [Select ID,Employee_Name__c,Phone_Number__c from Employee__C where Employee_Name__c
like :LikeCondition or Phone_Number__c like :LikeCondition ] ;
return objEmployee ;
}
public void Lookup()
{
gtEmployee();
}
}
Apex-Code:
public with sharing class EmployeeDemo
{
public List<Employee__c> listEmployee {get;set;}
public Employee__c objEmployee {get;set;}
Public String inputValue {get; set;}
Public String EmployeePhoneNumber {get; set;}
public string EmployeeName{get;set;}
Public String LikeCondition = '';
public string EmployeeID{get;set;}
public EmployeeDemo(ApexPages.StandardController controller)
{
objEmployee = new Employee__c();
}
public List<Employee__C> getEmployee()
{
try
{
LikeCondition = '%' + inputValue + '%' ;
listEmployee = [Select ID,Employee_Name__c,Phone_Number__c from Employee__C where Employee_Name__c like
:LikeCondition or Phone_Number__c like :LikeCondition ] ;
}
Catch (Exception ex)
{
System.debug('\n\nException ='+ex.getMessage()+'\n\n');
}
return listEmployee ;
}
public void Lookup()
{
getEmployee();
}
public PageReference Save()
{
Try
{
objEmployee.Employee_Name__c = EmployeeName;
objEmployee.Phone_Number__c = EmployeePhoneNumber;
if (EmployeeID!='')
{
objEmployee.ID = EmployeeID;
}
upsert objEmployee;
}
Catch (Exception ex)
{
System.debug('\n\nException ='+ex.getMessage()+'\n\n');
}
PageReference pr = new PageReference('/apex/ForDocument'); // To refresh the page again
pr.setRedirect(true);
return pr;
}
}
References:
As of now we have just taken the overview of SalesForce. In real SalesForce provides very robust technologies in the clod
computing model. Here are some links by which we can explore this model. These links include some PDF, Video, and HTML
tutorial:
Tools for Import and Export of data from one data base instance to SalesForce and vice versa:
https://help.salesforce.com/HTViewHelpDoc?id=import_which_data_import_tool.htm&language=en_US#
Workbooks by SalesForce
http://wiki.developerforce.com/page/Force.com_workbook
Pick-List Blog
http://writeforce.blogspot.in/2012/11/the-trouble-with-picklists-visualforce.html
Some useful Podcasts for Admin, Developer and Advance developer certification:
http://www.salesforcetrainingpodcasts.com/podcasts/
Wikipedia of SalesForce:
http://wiki.developerforce.com
Force.com Canvas
http://wiki.developerforce.com/page/Force.com_Canvas
Examples of Advanced Formula Fields
http://www.salesforce.com/us/developer/docs/usefulFormulaFields/