SlideShare a Scribd company logo
1 of 27
Development with Force.com




                  Luu Thanh Thuy

                  CWI Team
Agenda

- Overview of Force.com

-   Database

-   Business Logic

- User interface

- Integration




                www.exoplatform.com - Copyright 2012 eXo Platform   2
Overview of force.com


-Is part of Salesforce.com
-PaaS.
-Is free for developer
-Relational database
-Apex language . Its syntax is blend of Java and database
stored language.
-Force.com IDE




                www.exoplatform.com - Copyright 2012 eXo Platform   3
Database

-Objects : related to database tables. Contains custom and standard object.
-Logical, not Physical, Object
-Delegated Tuning and Operations
-Undelete Support
-Fields
-Unique Identifiers
-Validation rules
-Formula Fields

 Billable Revenue (Currency) = Week_Total_Hrs__c * Rate_Per_Hour__c
-Rich Data Types
-History tracking
-Relationships : one to one, one to many, many to many




                      www.exoplatform.com - Copyright 2012 eXo Platform       4
Query Language

-Force.com has two query langue: Salesforce Object Query Language (SOQL)
And Salesforce Object Search Language (SOSL)
  Select Name, Total_Billable_Revenue_Pending_Invoice__c
  From Proj__c
  where Invoiced__c= FALSE and Start_Date__c = LAST_QUARTER
  ORDER_BY Total_Billable_Revenue_Pending_Invoice__c DESC LIMIT 10

FIND ā€˜java*ā€™ in all fields returning
Project__c, Resource__c, Assignment__c, Skill__c

-No Function in Column list
-Governor Limits




                      www.exoplatform.com - Copyright 2012 eXo Platform    5
Object creation




                  www.exoplatform.com - Copyright 2012 eXo Platform   6
Database security

Security architectures as a funnel




                      www.exoplatform.com - Copyright 2012 eXo Platform   7
Security Architecture




               www.exoplatform.com - Copyright 2012 eXo Platform   8
Implementing the Security Model

-1. Create Profiles

-2. Configure Field Accessibility

-3. Set Organization-Wide default

-4. Establish Role hierarchy

-5. Adding Sharing Rule




                      www.exoplatform.com - Copyright 2012 eXo Platform   9
Database security




              www.exoplatform.com - Copyright 2012 eXo Platform   10
Business Logic

-Force IDE
-Apex language basic
-Database trigger
-Debugging and Testing




                   www.exoplatform.com - Copyright 2012 eXo Platform   11
Database trigger

Triggers are Apex code working in concert with the Force.com database
engine, automatically invoked by Force.com when database records are
modified.Trigger code can perform any necessary processing on the modified
data before or after Force.com




                     www.exoplatform.com - Copyright 2012 eXo Platform       12
Business Logic

_Save points :Savepoints are markers indicating the state of the database at a
specific point in the execution of your Apex program.They allow the database to
be restored to a known state in case of error or any scenario requiring a reversal
of all DML operations performed since the savepoint.

void printRecordCount() {
System.debug([ SELECT COUNT() FROM Resource__c ] + ' records');
}
printRecordCount();
Savepoint sp = Database.setSavepoint();
delete [ SELECT Id FROM Resource__c ];
printRecordCount();
Database.rollback(sp);
printRecordCount();
Database.rollback(sp);
printRecordCount();



                      www.exoplatform.com - Copyright 2012 eXo Platform          13
Business Logic

_ Record Locking prevent updates by one program have been modified by a
second program running at the same time.The changes of the second program
are lost because the first program is operating with stale data.

Resource__c tim = [ SELECT Id, Hourly_Cost_Rate__c
FROM Resource__c
WHERE Name = 'Tim Barr' LIMIT 1
FOR UPDATE ];
tim.Hourly_Cost_Rate__c += 20;
update tim;




                    www.exoplatform.com - Copyright 2012 eXo Platform       14
Business Logic

The three ways to send email in Apex are the following:
1. SingleEmailMessage: Sends an email to up to ten receivers.The email addresses of
   receivers are provided as strings. A string containing HTML or plain text is used as the
   message body.

2. SingleEmailMessage with Template: Sends to up to ten receivers, but the unique
    identifiers of Contact, Lead, or User objects must be used instead of strings
to provide the receiversā€™ email addresses.The message body is constructed from a
template.Templates are globally available to an organization as defined by an administrator
or private to an individual user.Templates can include merge fields to
dynamically substitute field values from the receiverā€™s record and, optionally, field
values from an additional, related object.


3. MassEmailMessage: Behaves like a SingleEmailMessage with template but can
send email to up to 250 receivers in a single call.




                         www.exoplatform.com - Copyright 2012 eXo Platform                    15
User Interfaces




                  www.exoplatform.com - Copyright 2012 eXo Platform   16
User Interfaces

_Visualforce controller : Standard controller, custom controller, Controller
   extension
1. Standard controller :Every database object has a standard controller. Its name
   is simply the name of the object. The implement is already provided by
   Force.com
2. Custom controller : no default functionality and consisting entirely of custom
Apex code

3. Controller extension : extends the standard controller




                      www.exoplatform.com - Copyright 2012 eXo Platform        17
User Interfaces :Modular Visualforce

Visualforce provide several features developer can use to create modular, highly
   maintainable pages.

1. Static resources : reusable images, scripts, stylesheets and other static
   content can be stored in resources, available for embeding in all Visualforce
   pages in the Force.com organization
2. Inclusion the contents of one Visualforce page can be included in another
   page. A common use for this is page headers and footers

3. Composition : Composition allows one Visualforce page to serve as a
   template for another. The template specifies the static and dynamic portions of
   a page
4. Custom Visualforce components: developers define their own custom
   components, reusable in any page




                      www.exoplatform.com - Copyright 2012 eXo Platform            18
Batch Processing

Batch processing is used for processing data exceeding the governor limits of
triggers and controller, allow you keep the large, data-intensive processing task
within the platform, taking advantage of its close proximity to the data and
transactional integrity.
Some key concepts in Batch Apex
1.Scope : is the set of records that a Batch Apex process operates on. It can
consist of 1 record or up to 50 million records. Scope is expressed as a SOQL
statement
2. Batch job : a batch job is a Batch Apex program that have been submitted for
execution. Batch job run in background an can take many hours to complete the
jobs. Salesforce provide user interface for listing batch jobs and their status and
allow individual jobs to be canceled.
3. Transaction : is up to 200 records. When a batch job start, the scope is split
into a series of transactions.




                       www.exoplatform.com - Copyright 2012 eXo Platform              19
Batchable Interface

In order to execute Batch job, Apex class must inplement Batchable interface, the
    logic processing following method

1. Start : run a QueryLocatior or an Iterable that describes the scope of the batch
   job.
2. Execute: After execute start, Force splits the records set into sets of up to 200
   records and invokes your execute method repeatedly
3. Finish ; the finish method is invoked once at the end of a batch job. You could
   use this method tho clear up any working state or notify the user via email that
   the batch job is completed




                      www.exoplatform.com - Copyright 2012 eXo Platform           20
Example




          www.exoplatform.com - Copyright 2012 eXo Platform   21
Stateful Batch Apex

Batch apex is stateless by default, means for each execution of your execute
method, you receive a fresh copy of your object. If your batch process needs
information that is shared across the transactions, make the Batch Apex class
stateful by implementing Stateful inferface.




                      www.exoplatform.com - Copyright 2012 eXo Platform         22
Limit Of Batch Apex

1. The maximum heap size in Batch Apex is 6 MB
2. Calling out to external systems using the HTTP object or webservice methods
   a limited to one for each invocation of start,execute and finish
3. Transactions run under the same governor limits as any Apex code
4. The maximum number of queued or active batch jobs within an entire
   Salesforce organization is five




                     www.exoplatform.com - Copyright 2012 eXo Platform       23
Integration
_Force.com support both SOAP and REST (xml or json)
_Force provides five types of Web service APIs :
Enterprise, Partner, Metadata, Apex , and Delegated Authentication

_The Enterprise API provides a strongly typed representation of the objects in
your Force.com. When you redefine an object or add a new object, the WSDL is
automatically update. You need manually download
_ The Partner API is designed for independent software vendor. They cannot repy
on a single, static representation of standard and custom object. With the partner
API , you can write generic code to access any object in any Force.com
organization




                      www.exoplatform.com - Copyright 2012 eXo Platform         24
Generating Stub Code


Force advises that you use the Force.com Web Service Connector (WSC) with its
Web services . http://code.google.com/p/sfdc-wsc. Copy WSC jar and
enterprise.wsdl into same folder




                     www.exoplatform.com - Copyright 2012 eXo Platform     25
Custom web service

-Global class access modifier
-Web service method. These method must be static
-Supporting class : user-defined Apex class, inner and outer that are arguments
or return values for a Web services must be defined as global. Member variables
of these classes must be defined using webservice keyword
-No Overloading : overloading method result in a compile error
-Prohibited types : the Map, Set, Pattern , Matcher, Exception and Enum types
are not allowed in the arguments or return types of Apex Webservices




                     www.exoplatform.com - Copyright 2012 eXo Platform        26
www.exoplatform.com - Copyright 2012 eXo Platform   27

More Related Content

What's hot

Obiee10 g to 11g upgrade
Obiee10 g to 11g upgradeObiee10 g to 11g upgrade
Obiee10 g to 11g upgrade
Amit Sharma
Ā 
Force.com migration utility
Force.com migration utilityForce.com migration utility
Force.com migration utility
Amit Sharma
Ā 
( 13 ) Office 2007 Coding With Excel And Excel Services
( 13 ) Office 2007   Coding With Excel And Excel Services( 13 ) Office 2007   Coding With Excel And Excel Services
( 13 ) Office 2007 Coding With Excel And Excel Services
LiquidHub
Ā 
Epicor 10-architected-for-efficiency-whitepaper
Epicor 10-architected-for-efficiency-whitepaperEpicor 10-architected-for-efficiency-whitepaper
Epicor 10-architected-for-efficiency-whitepaper
Le Quoc Vuong
Ā 

What's hot (20)

Esm migrate to_corre_6.0c
Esm migrate to_corre_6.0cEsm migrate to_corre_6.0c
Esm migrate to_corre_6.0c
Ā 
ESM_ServiceLayer_DevGuide_1.0.pdf
ESM_ServiceLayer_DevGuide_1.0.pdfESM_ServiceLayer_DevGuide_1.0.pdf
ESM_ServiceLayer_DevGuide_1.0.pdf
Ā 
R12 d49656 gc10-apps dba 03
R12 d49656 gc10-apps dba 03R12 d49656 gc10-apps dba 03
R12 d49656 gc10-apps dba 03
Ā 
R12 d49656 gc10-apps dba 05
R12 d49656 gc10-apps dba 05R12 d49656 gc10-apps dba 05
R12 d49656 gc10-apps dba 05
Ā 
R12 d49656 gc10-apps dba 08
R12 d49656 gc10-apps dba 08R12 d49656 gc10-apps dba 08
R12 d49656 gc10-apps dba 08
Ā 
R12 d49656 gc10-apps dba 10
R12 d49656 gc10-apps dba 10R12 d49656 gc10-apps dba 10
R12 d49656 gc10-apps dba 10
Ā 
Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4Spring review_for Semester II of Year 4
Spring review_for Semester II of Year 4
Ā 
R12 architectural changes
R12 architectural changesR12 architectural changes
R12 architectural changes
Ā 
Asset modelimportconn devguide_5.2.1.6190.0
Asset modelimportconn devguide_5.2.1.6190.0Asset modelimportconn devguide_5.2.1.6190.0
Asset modelimportconn devguide_5.2.1.6190.0
Ā 
Share point review qustions
Share point review qustionsShare point review qustions
Share point review qustions
Ā 
Obiee10 g to 11g upgrade
Obiee10 g to 11g upgradeObiee10 g to 11g upgrade
Obiee10 g to 11g upgrade
Ā 
SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3SCWCD : Servlet web applications : CHAP : 3
SCWCD : Servlet web applications : CHAP : 3
Ā 
R12 d49656 gc10-apps dba 02
R12 d49656 gc10-apps dba 02R12 d49656 gc10-apps dba 02
R12 d49656 gc10-apps dba 02
Ā 
Salesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command lineSalesforce Admin's guide : the data loader from the command line
Salesforce Admin's guide : the data loader from the command line
Ā 
SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3SCWCD : Servlet web applications : CHAP 3
SCWCD : Servlet web applications : CHAP 3
Ā 
Oracle ebs r12_architecture
Oracle ebs r12_architectureOracle ebs r12_architecture
Oracle ebs r12_architecture
Ā 
Force.com migration utility
Force.com migration utilityForce.com migration utility
Force.com migration utility
Ā 
( 13 ) Office 2007 Coding With Excel And Excel Services
( 13 ) Office 2007   Coding With Excel And Excel Services( 13 ) Office 2007   Coding With Excel And Excel Services
( 13 ) Office 2007 Coding With Excel And Excel Services
Ā 
Lunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's GuideLunacloud's Compute RESTful API - Programmer's Guide
Lunacloud's Compute RESTful API - Programmer's Guide
Ā 
Epicor 10-architected-for-efficiency-whitepaper
Epicor 10-architected-for-efficiency-whitepaperEpicor 10-architected-for-efficiency-whitepaper
Epicor 10-architected-for-efficiency-whitepaper
Ā 

Viewers also liked (7)

Products
ProductsProducts
Products
Ā 
Magento
MagentoMagento
Magento
Ā 
CampaƱas de sensibilizaciĆ³n
CampaƱas de sensibilizaciĆ³nCampaƱas de sensibilizaciĆ³n
CampaƱas de sensibilizaciĆ³n
Ā 
Sintaksis 5
Sintaksis 5Sintaksis 5
Sintaksis 5
Ā 
Congreso SEO 2012 Patrocinio
Congreso SEO 2012 PatrocinioCongreso SEO 2012 Patrocinio
Congreso SEO 2012 Patrocinio
Ā 
Rendimiento Web WPO para SEO
Rendimiento Web WPO para SEORendimiento Web WPO para SEO
Rendimiento Web WPO para SEO
Ā 
mhrod/mib admission brochure 2011-2013
mhrod/mib admission brochure 2011-2013mhrod/mib admission brochure 2011-2013
mhrod/mib admission brochure 2011-2013
Ā 

Similar to Development withforce

Adobe Flex4
Adobe Flex4 Adobe Flex4
Adobe Flex4
Rich Helton
Ā 
Introduction to apex
Introduction to apexIntroduction to apex
Introduction to apex
Rinku Saini
Ā 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3
Borni DHIFI
Ā 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
Martin Fousek
Ā 
Alfresco Architecture
Alfresco ArchitectureAlfresco Architecture
Alfresco Architecture
Noushad Kabeer
Ā 

Similar to Development withforce (20)

Salesforce
SalesforceSalesforce
Salesforce
Ā 
Basic of Oracle Application
Basic of Oracle ApplicationBasic of Oracle Application
Basic of Oracle Application
Ā 
Basic of oracle application Login steps
Basic of oracle application Login stepsBasic of oracle application Login steps
Basic of oracle application Login steps
Ā 
My Saminar On Php
My Saminar On PhpMy Saminar On Php
My Saminar On Php
Ā 
Adobe Flex4
Adobe Flex4 Adobe Flex4
Adobe Flex4
Ā 
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFacesJavaOne - 10 Tips for Java EE 7 with PrimeFaces
JavaOne - 10 Tips for Java EE 7 with PrimeFaces
Ā 
Synopsis
SynopsisSynopsis
Synopsis
Ā 
Introduction to apex
Introduction to apexIntroduction to apex
Introduction to apex
Ā 
IRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHPIRJET- Lightweight MVC Framework in PHP
IRJET- Lightweight MVC Framework in PHP
Ā 
Php
PhpPhp
Php
Ā 
MarGotAspect - An AspectC++ code generator for the mARGOt framework
MarGotAspect - An AspectC++ code generator for the mARGOt frameworkMarGotAspect - An AspectC++ code generator for the mARGOt framework
MarGotAspect - An AspectC++ code generator for the mARGOt framework
Ā 
OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3OpenERP Technical Memento V0.7.3
OpenERP Technical Memento V0.7.3
Ā 
As pnet
As pnetAs pnet
As pnet
Ā 
Readme
ReadmeReadme
Readme
Ā 
unit 3.docx
unit 3.docxunit 3.docx
unit 3.docx
Ā 
Php Web Frameworks
Php Web FrameworksPhp Web Frameworks
Php Web Frameworks
Ā 
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 201310 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
10 Tips for Java EE 7 with PrimeFaces - JavaOne 2013
Ā 
AtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMSAtoZ about TYPO3 v8 CMS
AtoZ about TYPO3 v8 CMS
Ā 
Flex Rails Pres
Flex Rails PresFlex Rails Pres
Flex Rails Pres
Ā 
Alfresco Architecture
Alfresco ArchitectureAlfresco Architecture
Alfresco Architecture
Ā 

More from adm_exoplatform (13)

E xo mobile_overview_best_practice_in_mobile_application_design
E xo mobile_overview_best_practice_in_mobile_application_designE xo mobile_overview_best_practice_in_mobile_application_design
E xo mobile_overview_best_practice_in_mobile_application_design
Ā 
Advance jquery-plugin
Advance jquery-pluginAdvance jquery-plugin
Advance jquery-plugin
Ā 
Hadoop
HadoopHadoop
Hadoop
Ā 
Jquery ui
Jquery uiJquery ui
Jquery ui
Ā 
Cmsms
CmsmsCmsms
Cmsms
Ā 
Jquery
JqueryJquery
Jquery
Ā 
Java application server in the cloud
Java application server in the cloudJava application server in the cloud
Java application server in the cloud
Ā 
I os
I osI os
I os
Ā 
Memory and runtime analysis
Memory and runtime analysisMemory and runtime analysis
Memory and runtime analysis
Ā 
Jvm mbeans jmxtran
Jvm mbeans jmxtranJvm mbeans jmxtran
Jvm mbeans jmxtran
Ā 
Git training
Git trainingGit training
Git training
Ā 
Cluster mode and plf cluster
Cluster mode and plf clusterCluster mode and plf cluster
Cluster mode and plf cluster
Ā 
Cluster mode and plf cluster
Cluster mode and plf clusterCluster mode and plf cluster
Cluster mode and plf cluster
Ā 

Recently uploaded

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
Ā 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
Ā 

Recently uploaded (20)

Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls šŸ„° 8617370543 Service Offer VIP Hot Model
Ā 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
Ā 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
Ā 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
Ā 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Ā 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
Ā 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
Ā 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Ā 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Ā 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
Ā 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Ā 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
Ā 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
Ā 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
Ā 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Ā 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Ā 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Ā 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Ā 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
Ā 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Ā 

Development withforce

  • 1. Development with Force.com Luu Thanh Thuy CWI Team
  • 2. Agenda - Overview of Force.com - Database - Business Logic - User interface - Integration www.exoplatform.com - Copyright 2012 eXo Platform 2
  • 3. Overview of force.com -Is part of Salesforce.com -PaaS. -Is free for developer -Relational database -Apex language . Its syntax is blend of Java and database stored language. -Force.com IDE www.exoplatform.com - Copyright 2012 eXo Platform 3
  • 4. Database -Objects : related to database tables. Contains custom and standard object. -Logical, not Physical, Object -Delegated Tuning and Operations -Undelete Support -Fields -Unique Identifiers -Validation rules -Formula Fields Billable Revenue (Currency) = Week_Total_Hrs__c * Rate_Per_Hour__c -Rich Data Types -History tracking -Relationships : one to one, one to many, many to many www.exoplatform.com - Copyright 2012 eXo Platform 4
  • 5. Query Language -Force.com has two query langue: Salesforce Object Query Language (SOQL) And Salesforce Object Search Language (SOSL) Select Name, Total_Billable_Revenue_Pending_Invoice__c From Proj__c where Invoiced__c= FALSE and Start_Date__c = LAST_QUARTER ORDER_BY Total_Billable_Revenue_Pending_Invoice__c DESC LIMIT 10 FIND ā€˜java*ā€™ in all fields returning Project__c, Resource__c, Assignment__c, Skill__c -No Function in Column list -Governor Limits www.exoplatform.com - Copyright 2012 eXo Platform 5
  • 6. Object creation www.exoplatform.com - Copyright 2012 eXo Platform 6
  • 7. Database security Security architectures as a funnel www.exoplatform.com - Copyright 2012 eXo Platform 7
  • 8. Security Architecture www.exoplatform.com - Copyright 2012 eXo Platform 8
  • 9. Implementing the Security Model -1. Create Profiles -2. Configure Field Accessibility -3. Set Organization-Wide default -4. Establish Role hierarchy -5. Adding Sharing Rule www.exoplatform.com - Copyright 2012 eXo Platform 9
  • 10. Database security www.exoplatform.com - Copyright 2012 eXo Platform 10
  • 11. Business Logic -Force IDE -Apex language basic -Database trigger -Debugging and Testing www.exoplatform.com - Copyright 2012 eXo Platform 11
  • 12. Database trigger Triggers are Apex code working in concert with the Force.com database engine, automatically invoked by Force.com when database records are modified.Trigger code can perform any necessary processing on the modified data before or after Force.com www.exoplatform.com - Copyright 2012 eXo Platform 12
  • 13. Business Logic _Save points :Savepoints are markers indicating the state of the database at a specific point in the execution of your Apex program.They allow the database to be restored to a known state in case of error or any scenario requiring a reversal of all DML operations performed since the savepoint. void printRecordCount() { System.debug([ SELECT COUNT() FROM Resource__c ] + ' records'); } printRecordCount(); Savepoint sp = Database.setSavepoint(); delete [ SELECT Id FROM Resource__c ]; printRecordCount(); Database.rollback(sp); printRecordCount(); Database.rollback(sp); printRecordCount(); www.exoplatform.com - Copyright 2012 eXo Platform 13
  • 14. Business Logic _ Record Locking prevent updates by one program have been modified by a second program running at the same time.The changes of the second program are lost because the first program is operating with stale data. Resource__c tim = [ SELECT Id, Hourly_Cost_Rate__c FROM Resource__c WHERE Name = 'Tim Barr' LIMIT 1 FOR UPDATE ]; tim.Hourly_Cost_Rate__c += 20; update tim; www.exoplatform.com - Copyright 2012 eXo Platform 14
  • 15. Business Logic The three ways to send email in Apex are the following: 1. SingleEmailMessage: Sends an email to up to ten receivers.The email addresses of receivers are provided as strings. A string containing HTML or plain text is used as the message body. 2. SingleEmailMessage with Template: Sends to up to ten receivers, but the unique identifiers of Contact, Lead, or User objects must be used instead of strings to provide the receiversā€™ email addresses.The message body is constructed from a template.Templates are globally available to an organization as defined by an administrator or private to an individual user.Templates can include merge fields to dynamically substitute field values from the receiverā€™s record and, optionally, field values from an additional, related object. 3. MassEmailMessage: Behaves like a SingleEmailMessage with template but can send email to up to 250 receivers in a single call. www.exoplatform.com - Copyright 2012 eXo Platform 15
  • 16. User Interfaces www.exoplatform.com - Copyright 2012 eXo Platform 16
  • 17. User Interfaces _Visualforce controller : Standard controller, custom controller, Controller extension 1. Standard controller :Every database object has a standard controller. Its name is simply the name of the object. The implement is already provided by Force.com 2. Custom controller : no default functionality and consisting entirely of custom Apex code 3. Controller extension : extends the standard controller www.exoplatform.com - Copyright 2012 eXo Platform 17
  • 18. User Interfaces :Modular Visualforce Visualforce provide several features developer can use to create modular, highly maintainable pages. 1. Static resources : reusable images, scripts, stylesheets and other static content can be stored in resources, available for embeding in all Visualforce pages in the Force.com organization 2. Inclusion the contents of one Visualforce page can be included in another page. A common use for this is page headers and footers 3. Composition : Composition allows one Visualforce page to serve as a template for another. The template specifies the static and dynamic portions of a page 4. Custom Visualforce components: developers define their own custom components, reusable in any page www.exoplatform.com - Copyright 2012 eXo Platform 18
  • 19. Batch Processing Batch processing is used for processing data exceeding the governor limits of triggers and controller, allow you keep the large, data-intensive processing task within the platform, taking advantage of its close proximity to the data and transactional integrity. Some key concepts in Batch Apex 1.Scope : is the set of records that a Batch Apex process operates on. It can consist of 1 record or up to 50 million records. Scope is expressed as a SOQL statement 2. Batch job : a batch job is a Batch Apex program that have been submitted for execution. Batch job run in background an can take many hours to complete the jobs. Salesforce provide user interface for listing batch jobs and their status and allow individual jobs to be canceled. 3. Transaction : is up to 200 records. When a batch job start, the scope is split into a series of transactions. www.exoplatform.com - Copyright 2012 eXo Platform 19
  • 20. Batchable Interface In order to execute Batch job, Apex class must inplement Batchable interface, the logic processing following method 1. Start : run a QueryLocatior or an Iterable that describes the scope of the batch job. 2. Execute: After execute start, Force splits the records set into sets of up to 200 records and invokes your execute method repeatedly 3. Finish ; the finish method is invoked once at the end of a batch job. You could use this method tho clear up any working state or notify the user via email that the batch job is completed www.exoplatform.com - Copyright 2012 eXo Platform 20
  • 21. Example www.exoplatform.com - Copyright 2012 eXo Platform 21
  • 22. Stateful Batch Apex Batch apex is stateless by default, means for each execution of your execute method, you receive a fresh copy of your object. If your batch process needs information that is shared across the transactions, make the Batch Apex class stateful by implementing Stateful inferface. www.exoplatform.com - Copyright 2012 eXo Platform 22
  • 23. Limit Of Batch Apex 1. The maximum heap size in Batch Apex is 6 MB 2. Calling out to external systems using the HTTP object or webservice methods a limited to one for each invocation of start,execute and finish 3. Transactions run under the same governor limits as any Apex code 4. The maximum number of queued or active batch jobs within an entire Salesforce organization is five www.exoplatform.com - Copyright 2012 eXo Platform 23
  • 24. Integration _Force.com support both SOAP and REST (xml or json) _Force provides five types of Web service APIs : Enterprise, Partner, Metadata, Apex , and Delegated Authentication _The Enterprise API provides a strongly typed representation of the objects in your Force.com. When you redefine an object or add a new object, the WSDL is automatically update. You need manually download _ The Partner API is designed for independent software vendor. They cannot repy on a single, static representation of standard and custom object. With the partner API , you can write generic code to access any object in any Force.com organization www.exoplatform.com - Copyright 2012 eXo Platform 24
  • 25. Generating Stub Code Force advises that you use the Force.com Web Service Connector (WSC) with its Web services . http://code.google.com/p/sfdc-wsc. Copy WSC jar and enterprise.wsdl into same folder www.exoplatform.com - Copyright 2012 eXo Platform 25
  • 26. Custom web service -Global class access modifier -Web service method. These method must be static -Supporting class : user-defined Apex class, inner and outer that are arguments or return values for a Web services must be defined as global. Member variables of these classes must be defined using webservice keyword -No Overloading : overloading method result in a compile error -Prohibited types : the Map, Set, Pattern , Matcher, Exception and Enum types are not allowed in the arguments or return types of Apex Webservices www.exoplatform.com - Copyright 2012 eXo Platform 26
  • 27. www.exoplatform.com - Copyright 2012 eXo Platform 27