Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Introduction to Force.com
1. Presented by :
Date :
Introduction to Force.com
Kaushik Chakraborty
6th Sept, 2012
2. a SEI-CMMi level 4 company
Agenda
• Salesforce.com
• Cloud Technology(What and Why)
• Force.com(a PAAS)
• Force.com Technologies
• Data - Force.com Database
• Logic - Apex
• View - Visual Force
• Demo
2
3. a SEI-CMMi level 4 company
Salesforce.com
Salesforce.com Inc. is a global enterprise software company headquartered in San
Fransisco, United States.
Founded : March 1999
Founders :
Marc Benioff (former Oracle executive)
Parker Harris, Dave Moellenhoff, and Frank Dominguez (three software developers previously at
Clarify).
Known for its (CRM) product, through acquisitions Salesforce has expanded into
the "social enterprise arena."
It was ranked number 27 in Fortune’s 100 Best Companies to Work For in 2012.
Salesforce.com's CRM solution is broken down into several broad categories:
Sales Cloud, Service Cloud, Data Cloud,(Data.com), Collaboration Cloud (Chatter) and Custom
Cloud(Force.com).
3
4. a SEI-CMMi level 4 company
Cloud Computing
What is Cloud Computing ?
Wikipedia says : Cloud computing is the use
of computing resources (hardware and software) that are delivered
as a service over a network (typically the Internet).
Typically its categorized into 3 types :
IAAS (Infrastructure As A Service)
Amazon EC2, Google Cloud Engine.
PAAS (Platform As A Service)
Heroku, Force.com
SAAS (Software As A Service)
Google Apps, Limelight Video Platform
4
5. a SEI-CMMi level 4 company
Cloud Computing
Why Do we need Cloud Computing Service ?
“LESSER INVESTMENT”
Reduced personal infrastructure
Reduced head count
On Demand Service
5
Cloud computing logical diagram
6. a SEI-CMMi level 4 company
Force.com(a PAAS)
Force.com is a cloud computing platform as a service system
from Salesforce.com that developers use to build multi tenant
applications hosted on their servers as a service.
Advantages :
RAD Platform – Lots of available features/functionalities from Salesforce
User management and authentication
Administrative interface
Reporting and analytics
Enforces best practices
Actively under development (Big things underway with VMForce - the enterprise cloud for Java developers.)
No Prerequisites : Only a Computer with an internet connection
Disadvantages:
Apex(Force.com programming language) not Fully Featured Language
Debugging is a Nightmare as there is no real time debugger
Unfixed bugs
Checking the uploaded resources(.css, images , .js)
Data based pricing makes it pricy for folks with lots of data.
Force.com IDE doesn’t provide usability like Eclipse.
6
7. a SEI-CMMi level 4 company
Force.com Technologies
7
Visual Force Page 1
Apex Controller 3Apex Controller 2Apex Controller 1
Visual Force Page 2 Visual Force Page 3
Apex Classes
sObject 1
Trigger 2Trigger 1
sObject 2 sObject 3
Visual Force Pages
Apex Logic
(Controllers, Class , Triggers))
Database Objects
8. a SEI-CMMi level 4 company
Force.com Technologies (The Database)
The Lingo(Old New)
Tables Objects
Columns Fields
Keys Ids
Foreign Keys Relationships
Row Record
Types of Objects :
Standard Objects – Provided by force.com per profile(Account, Attachment)
refer to : http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_list.htm
Custom Objects – Created by the user
8
9. a SEI-CMMi level 4 company
Force.com Technologies (The Database)
The joy of data types :
Lookup Fields
Master Detail Fields
Roll up Summary
Formula Fields
Rich Text
Email
Currency
Percentage
Picklist and Picklist(Multiselect)
URL
Number
Text
Long Text
Date
Checkbox
9
Read Only Fields
Relational Fields
Non Relational Fields
10. a SEI-CMMi level 4 company
Force.com Technologies (The Database)
The Query Languages :
SOQL (Salesforce Object Query Language) : A close cousin of SQL(but is not as
advanced), used to construct query strings
Basic Syntax :
SELECT fieldList FROM objectType
[WHERE conditionExpression]
[GROUP BY fieldGroupByList]
[HAVING havingConditionExpression]
[ORDER BY fieldOrderByList ASC | DESC ? NULLS FIRST | LAST ?]
[LIMIT number of rows to return ?]
[OFFSET number of rows to skip?]
SOSL (Salesforce Object Search Language) : It is used to create search strings
Basic Syntax :
FIND {SearchQuery} [toLabel()]
[IN SearchGroup [convertCurrency(Amount)]]
[RETURNING FieldSpec]
[LIMIT n]
Refer to : http://www.salesforce.com/us/developer/docs/soql_sosl/index.htm
10
11. a SEI-CMMi level 4 company
Force.com Technologies (The Database)
When to use SOQL?
You know in which objects or fields the data resides
You want to retrieve data from a single object or from multiple objects that are related to one another
You want to count the number of records that meet particular criteria
You want to sort your results as part of the query
You want to retrieve data from number, date, or checkbox fields
When to use SOSL?
You don’t know in which object or field the data resides and you want to find it in the most efficient way
possible
You want to retrieve multiple objects and fields efficiently, and the objects may or may not be related to
one another
You want to retrieve data for a particular division in an organization with Divisions, and you want to find it
in the most efficient way possible
11
12. a SEI-CMMi level 4 company
Force.com Technologies (The Database)
SOQL vs SOQL : What it returns ?
SOQL statements evaluate to a list of sObjects, a single sObject, or an Integer for count method queries.
Returns an empty list if no records are found.
SOSL statements evaluate to a list of lists of sObjects, where each list contains the search results for a
particular sObject type. The result lists are always returned in the same order as they were specified in the
SOSL query. SOSL queries are only supported in Apex classes and anonymous blocks. You cannot use a
SOSL query in a trigger. If a SOSL query does not return any records for a specified sObject type, the search
results include an empty list for that sObject.
12
List<Account> accounts = [SELECT Id, Name FROM Account WHERE Name = 'Acme'];
List<List<SObject>> searchList = [FIND 'map*' IN ALL FIELDS
RETURNING Account (Id, Name),
Contact, Opportunity, Lead];
Account [] accounts = ((List<Account>)searchList[0]);
Contact [] contacts = ((List<Contact>)searchList[1]);
Opportunity [] opportunities = ((List<Opportunity>)searchList[2]);
Lead [] leads = ((List<Lead>)searchList[3]);
13. a SEI-CMMi level 4 company
Force.com Technologies (Apex)
What’s is similar to :
A programming language
Syntax close to C# and Java
Compiled
Strongly typed language(String , Integer etc.)
Can be used like database stored procedures / triggers (similar to TSQL in SqlServer and
PL/SQL in Oracle)
How it is different:
Runs natively on force.com
Testing a Class from the same Class
Coding in the browser
13
14. a SEI-CMMi level 4 company
Force.com Technologies (Apex)
Apex Code : What it looks like ?
14
Data
Operation
Array
Control
Structure
SOQL QueryVariable
Declaration
15. a SEI-CMMi level 4 company
Force.com Technologies (Apex)
A trigger is an Apex code that executes before or after the following
types of operations :
Insert
Update
Delete
Upsert (update or insert)
Undelete
A sample Trigger :
15
trigger HandleModifiedDateOnCustomer on Customer__c (before update) {
for(Customer__c customer : Trigger.NEW){
customer.Modified_Date__c = Date.TODAY();
}
}
16. a SEI-CMMi level 4 company
Force.com Technologies (Visual Force)
Visualforce is a framework that allows developers to build sophisticated, custom user
interfaces that can be hosted natively on the Force.com platform.
Supported Browsers
Microsoft® Internet Explorer® versions 7, 8, and 9
Mozilla® Firefox®, most recent stable version
Google Chrome™, most recent stable version
Google Chrome Frame™ plug-in for Microsoft® Internet Explorer® 6
Apple® Safari® version 5.1.x
16
17. a SEI-CMMi level 4 company
Force.com Technologies (Visualforce)
17
KEY FEATURES :
PAGES
Use Standard Web Technologies including HTML and JavaScript
Are rendered in HTML
Can include components , Force.com Expressions, HTML, JS, Flash and
more.
COMPONENTS
Are reusable standard Salesforce and custom – designed UI components
Are referenced over a tag library model with over 65 standard elements
Can be created for resuse
CONTROLLERS
Types : Standard and Custom(Apex)
Provides data from the database to the Visualforce pages
A set of instruction that specify what happens when a user interacts
with the components in the Visualforce page like a button click.
Visualforce
Pages
(Parent – Component)
Child
Components
Controllers
Request
Response
18. a SEI-CMMi level 4 company
Force.com Technologies (Visual Force)
18
19. a SEI-CMMi level 4 company
Force.com Technologies (Visual Force)
Expression Syntax
There are three types of bindings for Visualforce Components :
Data Bindings : uses the expression syntax to pull data from the data set made available by
the page controller.
Action Bindings : uses the expression syntax to call action methods for functions coded by
the page controller.
Component Bindings : uses components attribute values to reference other components’
ID’s
19
<apex:inputField value=“{!Student__c.Name__c}”/>
<apex:commandButton value=“Save” action=“{!saveStudent}”/>
<apex:attribute name=“text” type=“String” description=“My text value to display”/>
……………..
…………….
<h1>{!text}</h1>
20. a SEI-CMMi level 4 company
Force.com Technologies (Visual Force)
Intelligent Component : <apex:inputField />
20
21. a SEI-CMMi level 4 company
Force.com Technologies (Visual Force)
Other features :
Inclusion of Static Resources (.css , .js , jquery)
Including Custom Java Scripts and styles
Rendering a PDF can get easier
21