Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Development withforce


Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Development withforce

  1. 1. Development with Luu Thanh Thuy CWI Team
  2. 2. Agenda- Overview of Database- Business Logic- User interface- Integration - Copyright 2012 eXo Platform 2
  3. 3. Overview of part of free for developer-Relational database-Apex language . Its syntax is blend of Java and databasestored IDE - Copyright 2012 eXo Platform 3
  4. 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 - Copyright 2012 eXo Platform 4
  5. 5. Query 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 - Copyright 2012 eXo Platform 5
  6. 6. Object creation - Copyright 2012 eXo Platform 6
  7. 7. Database securitySecurity architectures as a funnel - Copyright 2012 eXo Platform 7
  8. 8. Security Architecture - Copyright 2012 eXo Platform 8
  9. 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 - Copyright 2012 eXo Platform 9
  10. 10. Database security - Copyright 2012 eXo Platform 10
  11. 11. Business Logic-Force IDE-Apex language basic-Database trigger-Debugging and Testing - Copyright 2012 eXo Platform 11
  12. 12. Database triggerTriggers are Apex code working in concert with the databaseengine, automatically invoked by when database records aremodified.Trigger code can perform any necessary processing on the modifieddata before or after - Copyright 2012 eXo Platform 12
  13. 13. 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(); - Copyright 2012 eXo Platform 13
  14. 14. 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; - Copyright 2012 eXo Platform 14
  15. 15. 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. - Copyright 2012 eXo Platform 15
  16. 16. User Interfaces - Copyright 2012 eXo Platform 16
  17. 17. 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 - Copyright 2012 eXo Platform 17
  18. 18. 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 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 - Copyright 2012 eXo Platform 18
  19. 19. 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. - Copyright 2012 eXo Platform 19
  20. 20. 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 - Copyright 2012 eXo Platform 20
  21. 21. Example - Copyright 2012 eXo Platform 21
  22. 22. 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. - Copyright 2012 eXo Platform 22
  23. 23. 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 - Copyright 2012 eXo Platform 23
  24. 24. 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 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 - Copyright 2012 eXo Platform 24
  25. 25. Generating Stub CodeForce advises that you use the Web Service Connector (WSC) with itsWeb services . Copy WSC jar andenterprise.wsdl into same folder - Copyright 2012 eXo Platform 25
  26. 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 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 - Copyright 2012 eXo Platform 26
  27. 27. - Copyright 2012 eXo Platform 27