• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Development withforce
 

Development withforce

on

  • 595 views

 

Statistics

Views

Total Views
595
Views on SlideShare
595
Embed Views
0

Actions

Likes
0
Downloads
29
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Development withforce Development withforce Presentation Transcript

    • 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 databasestored 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 10FIND ‘java*’ in all fields returningProject__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 securitySecurity 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 triggerTriggers are Apex code working in concert with the Force.com databaseengine, automatically invoked by Force.com when database records aremodified.Trigger code can perform any necessary processing on the modifieddata 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 aspecific point in the execution of your Apex program.They allow the database tobe restored to a known state in case of error or any scenario requiring a reversalof 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 asecond program running at the same time.The changes of the second programare lost because the first program is operating with stale data.Resource__c tim = [ SELECT Id, Hourly_Cost_Rate__cFROM Resource__cWHERE Name = Tim Barr LIMIT 1FOR UPDATE ];tim.Hourly_Cost_Rate__c += 20;update tim; www.exoplatform.com - Copyright 2012 eXo Platform 14
    • Business LogicThe 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 stringsto provide the receivers’ email addresses.The message body is constructed from atemplate.Templates are globally available to an organization as defined by an administratoror private to an individual user.Templates can include merge fields todynamically substitute field values from the receiver’s record and, optionally, fieldvalues from an additional, related object.3. MassEmailMessage: Behaves like a SingleEmailMessage with template but cansend 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 extension1. 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.com2. Custom controller : no default functionality and consisting entirely of customApex code3. Controller extension : extends the standard controller www.exoplatform.com - Copyright 2012 eXo Platform 17
    • User Interfaces :Modular VisualforceVisualforce 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 organization2. Inclusion the contents of one Visualforce page can be included in another page. A common use for this is page headers and footers3. Composition : Composition allows one Visualforce page to serve as a template for another. The template specifies the static and dynamic portions of a page4. Custom Visualforce components: developers define their own custom components, reusable in any page www.exoplatform.com - Copyright 2012 eXo Platform 18
    • Batch ProcessingBatch processing is used for processing data exceeding the governor limits oftriggers and controller, allow you keep the large, data-intensive processing taskwithin the platform, taking advantage of its close proximity to the data andtransactional integrity.Some key concepts in Batch Apex1.Scope : is the set of records that a Batch Apex process operates on. It canconsist of 1 record or up to 50 million records. Scope is expressed as a SOQLstatement2. Batch job : a batch job is a Batch Apex program that have been submitted forexecution. Batch job run in background an can take many hours to complete thejobs. Salesforce provide user interface for listing batch jobs and their status andallow individual jobs to be canceled.3. Transaction : is up to 200 records. When a batch job start, the scope is splitinto a series of transactions. www.exoplatform.com - Copyright 2012 eXo Platform 19
    • Batchable InterfaceIn order to execute Batch job, Apex class must inplement Batchable interface, the logic processing following method1. 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 repeatedly3. 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 ApexBatch apex is stateless by default, means for each execution of your executemethod, you receive a fresh copy of your object. If your batch process needsinformation that is shared across the transactions, make the Batch Apex classstateful by implementing Stateful inferface. www.exoplatform.com - Copyright 2012 eXo Platform 22
    • Limit Of Batch Apex1. The maximum heap size in Batch Apex is 6 MB2. Calling out to external systems using the HTTP object or webservice methods a limited to one for each invocation of start,execute and finish3. Transactions run under the same governor limits as any Apex code4. 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 inyour Force.com. When you redefine an object or add a new object, the WSDL isautomatically update. You need manually download_ The Partner API is designed for independent software vendor. They cannot repyon a single, static representation of standard and custom object. With the partnerAPI , you can write generic code to access any object in any Force.comorganization www.exoplatform.com - Copyright 2012 eXo Platform 24
    • Generating Stub CodeForce advises that you use the Force.com Web Service Connector (WSC) with itsWeb services . http://code.google.com/p/sfdc-wsc. Copy WSC jar andenterprise.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 argumentsor return values for a Web services must be defined as global. Member variablesof 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 typesare 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