Your SlideShare is downloading. ×
0
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Intro to Apex Programmers
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

Intro to Apex Programmers

5,899

Published on

If you are familiar with object-oriented languages like Java or C#, Apex may be the language you already almost know. Apex is the cloud-based programming language used on the Salesforce1 Platform to …

If you are familiar with object-oriented languages like Java or C#, Apex may be the language you already almost know. Apex is the cloud-based programming language used on the Salesforce1 Platform to take your enterprise applications to the next level. In this webinar, get an introduction to how Apex is similar to other languages, how you can start coding in Apex with just a web browser, and an overview of the many functions Apex can perform for your applications and users.

Key Takeaways
Programmers familiar with object-oriented languages will be able to learn Apex easily
Apex can perform a wide range of functions from serving as a controller for Visualforce pages to scheduled tasks in the background.

Published in: Technology
0 Comments
9 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
5,899
On Slideshare
0
From Embeds
0
Number of Embeds
7
Actions
Shares
0
Downloads
235
Comments
0
Likes
9
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Introduction to Apex for Programmers March 27, 2014
  • 2. #forcewebinar Safe Harbor Safe harbor statement under the Private Securities Litigation Reform Act of 1995: This presentation may contain forward-looking statements that involve risks, uncertainties, and assumptions. If any such uncertainties materialize or if any of the assumptions proves incorrect, the results of salesforce.com, inc. could differ materially from the results expressed or implied by the forward-looking statements we make. All statements other than statements of historical fact could be deemed forward-looking, including any projections of product or service availability, subscriber growth, earnings, revenues, or other financial items and any statements regarding strategies or plans of management for future operations, statements of belief, any statements concerning new, planned, or upgraded services or technology developments and customer contracts or use of our services. The risks and uncertainties referred to above include – but are not limited to – risks associated with developing and delivering new functionality for our service, new products and services, our new business model, our past operating losses, possible fluctuations in our operating results and rate of growth, interruptions or delays in our Web hosting, breach of our security measures, the outcome of intellectual property and other litigation, risks associated with possible mergers and acquisitions, the immature market in which we operate, our relatively limited operating history, our ability to expand, retain, and motivate our employees and manage our growth, new releases of our service and successful customer deployment, our limited history reselling non- salesforce.com products, and utilization and selling to larger enterprise customers. Further information on potential factors that could affect the financial results of salesforce.com, inc. is included in our annual report on Form 10-Q for the most recent fiscal quarter ended July 31, 2012. This documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Web site. Any unreleased services or features referenced in this or other presentations, press releases or public statements are not currently available and may not be delivered on time or at all. Customers who purchase our services should make the purchase decisions based upon features that are currently available. Salesforce.com, inc. assumes no obligation and does not intend to update these forward-looking statements.
  • 3. #forcewebinar Speakers Joshua Birk Developer Evangelist @joshbirk LeeAnne Templeman Developer Evangelist @leeanndroid
  • 4. #forcewebinar Follow Developer Force for the Latest News @forcedotcom / #forcewebinar Developer Force – Force.com Community Developer Force Developer Force Group +Developer Force – Force.com Community
  • 5. #forcewebinar Have Questions? §  We have an expert support team at the ready to answer your questions during the webinar. §  Ask your questions via the GoToWebinar Questions Pane. §  The speaker(s) will chose top questions to answer live at the end of the webinar. §  Please post your questions as we go along! §  Only post your question once; we’ll get to it as we go down the list.
  • 6. #forcewebinar Introduction to Apex §  What is Apex? §  Developing in your browser §  Apex Controllers §  Apex Triggers §  Other Apex Use Cases
  • 7. #forcewebinar Declarative Apps
  • 8. #forcewebinar Declarative and Programmatic Declarative Programmatic Visualforce Pages Visualforce Components Apex Controllers Apex Triggers Metadata API REST API Bulk API Workflows Validation Rules Approval Processes Objects Fields Relationships Page Layouts Record Types User Interface Business Logic Data Model
  • 9. #forcewebinar Apex
  • 10. #forcewebinar Introduction to Apex Chapter 1: §  Object-Oriented Language §  Dot Notation Syntax §  Developed, Compiled and Deployed in the Cloud §  “First Class” Citizen on the Platform
  • 11. #forcewebinar Every Object, Every Field: Apex and Visualforce Enabled Visualforce Pages Visualforce Components Apex Controllers Apex Triggers Custom UI Custom Logic
  • 12. #forcewebinar Apex Class Structure Chapter 1: public with sharing class myControllerExtension implements Util {
 
 private final Account acct;
 public Contact newContact {get; set;}
 public myControllerExtension(ApexPages.StandardController stdController) {
 this.acct = (Account)stdController.getRecord();
 }
 
 public PageReference associateNewContact(Id cid) {
 newContact = [SELECT Id, Account from Contact WHERE Id =: cid LIMIT 1];
 newContact.Account = acct;
 update newContact;
 }
 }
 Class and Interface based Scoped Variables Inline SOQL Inline DML þ þ þ þ
  • 13. #forcewebinar Developer Console •  Browser Based •  Create and Edit Classes •  Create and Edit Triggers •  Run Unit Tests •  Review Debug Logs
  • 14. #forcewebinar Apex Controllers •  Logic for User Interfaces •  Custom Controllers or Extensions •  Transport via: •  Viewstate •  JavaScript
  • 15. #forcewebinar Interacting with Apex Annotated Apex methods exposed to JavaScript Visualforce Forms Visualforce component bound to an Apex Method JavaScript Remoting
  • 16. #forcewebinar Apex Triggers §  Event Based Logic §  Associated with Object Types §  Before or After: §  Insert §  Update §  Delete §  Undelete
  • 17. #forcewebinar Controlling Flow trigger LineItemTrigger on Line_Item__c (before insert, before update) { 
 
 //separate before and after if(Trigger.isBefore) {
 
 //separate events if(Trigger.isInsert) { System.debug(‘BEFORE INSERT’); DelegateClass.performLogic(Trigger.new);
  • 18. #forcewebinar Controlling Flow trigger LineItemTrigger on Line_Item__c (before insert, before update) { 
 
 //separate before and after if(Trigger.isBefore) {
 
 //separate events if(Trigger.isInsert) { System.debug(‘BEFORE INSERT’); DelegateClass.performLogic(Trigger.new);
  • 19. #forcewebinar Static Flags public with sharing class AccUpdatesControl {
 // This class is used to set flag to prevent multiple calls
 public static boolean calledOnce = false;
 
 public static boolean ProdUpdateTrigger = false;
 
 }
  • 20. #forcewebinar Chatter Triggers trigger AddRegexTrigger on Blacklisted_Word__c (before insert, before update) {
 
 for (Blacklisted_Word__c f : trigger.new)
 {
 if(f.Custom_Expression__c != NULL)
 {
 f.Word__c = '';
 f.Match_Whole_Words_Only__c = false;
 f.RegexValue__c = f.Custom_Expression__c;
 }
 }
 }
  • 21. #forcewebinar Scheduled Apex
  • 22. #forcewebinar Schedulable Interface global with sharing class WarehouseUtil implements Schedulable {
 
 //General constructor
 global WarehouseUtil() {}
 
 //Scheduled execute
 global void execute(SchedulableContext ctx) {
 //Use static method for checking dated invoices
 WarehouseUtil.checkForDatedInvoices(); 
 }
  • 23. #forcewebinar Schedulable Interface System.schedule('testSchedule','0 0 13 * * ?', new WarehouseUtil());
 
 Via Apex Via Web UI
  • 24. #forcewebinar Batch Apex
  • 25. #forcewebinar Batchable Interface global with sharing class WarehouseUtil implements Database.Batchable<sObject> {
 
 //Batch execute interface
 global Database.QueryLocator start(Database.BatchableContext B //Start on next context
 }
 
 global void execute(Database.BatchableContext BC, List<sObject> scop //Execute on current scope
 }
 
 global void finish(Database.BatchableContext BC) { 
 //Finish and clean up context
 }

  • 26. #forcewebinar Apex Endpoints
  • 27. #forcewebinar Apex REST @RestResource(urlMapping='/CaseManagement/v1/*')
 global with sharing class CaseMgmtService
 {
 
 @HttpPost
 global static String attachPic(){
 RestRequest req = RestContext.request;
 RestResponse res = Restcontext.response;
 Id caseId = req.requestURI.substring(req.requestURI.lastIndexOf('/')+1);
 Blob picture = req.requestBody;
 Attachment a = new Attachment (ParentId = caseId,
 Body = picture,
 ContentType = 'image/
  • 28. #forcewebinar Unit Testing •  Declare Classes/Code as Test •  isTest Annotation •  testmethod keyword •  Default data scope is test only •  75% coverage required
  • 29. #forcewebinar Governor Limits •  System Level Limits •  Examples include: •  150 DML calls •  10 callouts •  More in the Apex Workbook •  Chapter 3, Tutorial #13
  • 30. #forcewebinar Bulkify Logic // For loop to iterate through all the queried Account records ! for(Account a: accountsWithContacts){! // Use the child relationships dot syntax to access the related Contacts! for(Contact c: a.Contacts){! !contactsToUpdate.add(c);! } ! }! ! //Now outside the FOR Loop, perform a single Update DML statement. ! update contactsToUpdate; ! ! http://wiki.developerforce.com/page/Apex_Code_Best_Practices
  • 31. #forcewebinar Recap §  What is Apex? §  Developing in your browser §  Apex Controllers §  Apex Triggers §  Other Apex Use Cases
  • 32. #forcewebinar Resources §  Your Developer Edition –  http://developer.force.com/join §  Force.com Workbook –  http://developer.force.com/workbooks §  Apex Workbook –  http://developer.force.com/workbooks
  • 33. Q & A #forcewebinar Joshua Birk Developer Evangelist @joshbirk LeeAnne Templeman Developer Evangelist @leeanndroid

×