Diese Präsentation wurde erfolgreich gemeldet.
Die SlideShare-Präsentation wird heruntergeladen. ×

Programming Building Blocks for Admins

Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Anzeige
Wird geladen in …3
×

Hier ansehen

1 von 36 Anzeige

Programming Building Blocks for Admins

Herunterladen, um offline zu lesen

Sometimes the biggest blocker to understanding code or starting to write Apex is not having foundational knowledge of the basic building blocks of programming with the Salesforce Platform. In this webinar, Admins will learn the basics of object oriented programming: what they are, how they're used, and even some best practices to take note of in your own org.

Sometimes the biggest blocker to understanding code or starting to write Apex is not having foundational knowledge of the basic building blocks of programming with the Salesforce Platform. In this webinar, Admins will learn the basics of object oriented programming: what they are, how they're used, and even some best practices to take note of in your own org.

Anzeige
Anzeige

Weitere Verwandte Inhalte

Diashows für Sie (20)

Ähnlich wie Programming Building Blocks for Admins (20)

Anzeige

Weitere von Salesforce Admins (11)

Anzeige

Programming Building Blocks for Admins

  1. 1. Programming Building Blocks for Admins
  2. 2. Kieren Jameson Senior Technical Writer Trailhead Content Salesforce @angMorriesette Black Girls Code (Curriculum Lead, Houston Chapter) Angelica Morriesette Director Trailhead Content Engineering Salesforce @kierenjameson RAD Women Co-Founder RadWomen.org WomenCodeHeroes.com Today’s Speakers
  3. 3. Forward-Looking Statement 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 any litigation, risks associated with completed and any 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-K for the most recent fiscal year and in our quarterly report on Form 10-Q for the most recent fiscal quarter. These documents and others containing important disclosures are available on the SEC Filings section of the Investor Information section of our Website. 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. Statement under the Private Securities Litigation Reform Act of 1995
  4. 4. Connect with Us! @SalesforceAdmns #AwesomeAdmin admin.salesforce.com Salesforce Admins Salesforce Admins Salesforce Admins
  5. 5. Watch the Recording The video will be posted to YouTube & the webinar recap page: bit.ly/programmingbuildingblocks This webinar is being recorded!
  6. 6. Join the Admin Webinar Group for Q&A! bit.ly/AdminWebinarGroup Don’t wait until the end to ask your question! We have team members on hand to answer questions in the webinar group. Stick around for live Q&A at the end! Speakers will tackle more questions at the end, time- allowing
  7. 7. • Show 8 key building blocks for coding • Relate blocks to Salesforce UI • Introduce best practices • Resources • Q&A Today’s Agenda
  8. 8. The Story Behind Our Presentation BOTanicals makes robotic flowers, the environmental and hypoallergenic alternative to traditional flowers. We’ll learn how to write Apex code to trigger the creation of a task to conduct a review of the top accounts for BOTanicals.
  9. 9. BOTanical Object Model Account Task Account Name (ID) We’ll do most of our coding around these two objects OwnerId WhatId Subject Status Priority
  10. 10. Classes, Variables, and Methods sObjects Triggers Lists & For Loops Data Manipulation Language (DML) Salesforce Object Query Language (SOQL) Building Blocks of Coding
  11. 11. Building Block: Classes A Class is where we put all our business logic for controlling records. Methods are units of code within a class that do things (e.g., creating a task). Variables are like temporary fields and can live either in the class or within a method (e.g., the status or priority of a task).
  12. 12. Building Block: Variables & Methods Variables are like fields. Methods are like quick actions. Variables for Account Methods for Account Name = 'Alsarraf Enterprises'; ID = '0012E00001rZpUUQA0'; Active = TRUE; Employees = 10; Phone ='111-222-3333'; ParentID = NULL; addToCampaign(); createAccount(); calculateValue(); The ; at the end of a line of code is like a period at the end of a sentence. It defines where a section of code ends.
  13. 13. Create a Class in Code security for class type of building block name of class code comment public class AccountUtility { // methods and variables here }
  14. 14. Create a Method in Code code comment security for class name of method data (parameter) being fed to the method what’s sent back from method public void calculateValue(){ //code that calculates value of account }
  15. 15. Classes, Variables, and Methods sObjects Triggers Lists & For Loops Data Manipulation Language (DML) Salesforce Object Query Language (SOQL) Building Blocks of Coding
  16. 16. A Special Type of Variable: sObjects Account sObject sObject variables store entire Salesforce records ID: 0012E00001rZpUUQA0 Account Name: Alsarraf Enterprises First Name: Shaiyma Last Name: Alsarraf Phone: 555-222-2222 WhatId: 8022E00000AKxziQAD Owner Id: 00000102 Subject: Alsarraf Enterprises Conduct Top account review Status: Closed Priority: Normal. Task sObject
  17. 17. Variables as They Relate to Salesforce UI Elements String Text, Text Area, Auto Number, URL, Phone, Email, Picklist Integer & Decimal Number, Percent, Currency Boolean Checkbox Date & DateTime Date, DateTime
  18. 18. Create an sObject Account with Apex what to call the sObject variable system method used to create the new sObject Task t = new Task( WhatId = currentAcct.id, OwnerId = userID, Subject = 'Email', Status = 'Open', Priority = 'Normal' ); what type of sObject
  19. 19. Classes, Variables, and Methods sObjects Triggers Lists & For Loops Data Manipulation Language (DML) Salesforce Object Query Language (SOQL) Building Blocks of Coding
  20. 20. Building Block: Triggers Triggers kick off code-based automated processes in Salesforce. They listen for certain database events— when a record is inserted, updated, deleted, etc.—and then do things. Best practices ● Treat triggers as TOCs—put business logic in classes not triggers ● Only have one trigger per object Change(s) made to records in org Trigger says, “Oooh, I know what to do!” Trigger sends all the records that were changed to a piece of code that does something with these records. END Method2 within a class Method3 within a class Method1 within a class
  21. 21. Create a Trigger in Code Trigger accountTrigger on Account (after update){ // Best Practice #1: Don’t put your business logic here. // Use the trigger as a table of contents and link out to // code within classes. // Best Practice #2: Have only one trigger per object. } name of trigger which Salesforce object to listen to when to run (e.g., before or after insert, update, or delete) type of OOP building block
  22. 22. Classes, Variables, and Methods sObjects Triggers Lists & For Loops Data Manipulation Language (DML) Salesforce Object Query Language (SOQL) Building Blocks of Coding
  23. 23. Building Block: Lists name of list what the list stores system method used to create an empty list sObjects List<Task> newTasks = new List<Task>(); //create a new task to add to the newTask list Task t = new Task( WhatId = currentAcct.id, Subject = currentAcct + ' conduct top account review' ); //add the t task to the newTask list newTasks.add(t); name of list variable Lists are a type of variable and they store groups of things (like a group of tasks). Lists are a type of collection. system method used to add something to a list
  24. 24. building block for(Accounts currentAccount : newAccountsFromTrigger){ //do something for to each account in the newAccounts list } variable type Building Block: For Loops name of the current list item being looped over list to loop over For loops are used to loop over a group of things (e.g., a list) and perform some action on each member of the group. loop over list items
  25. 25. Lists & For Loops in Action public class AccountUtility { public static void calculateValue(List<Account> newAccountsFromTrigger){ List<Task> newTasks = new List<Task>(); //create a List for(Account currentAcct : newAccountsFromTrigger){ //loop over accounts from trigger if(currentAcct.top_Account__c == TRUE ){ Task t = new Task( WhatId = currentAcct.id, Subject = currentAcct + ' conduct top account review' // we’d add more variables here ); newTasks.add(t); //add task ‘t’ to the list } //end if } //end for loop } //end method } //end class
  26. 26. Classes, Variables, and Methods sObjects Triggers Lists & For Loops Data Manipulation Language (DML) Salesforce Object Query Language (SOQL) Building Blocks of Coding
  27. 27. List<Task> newTasks = new List<Task>(); Task t = new Task( WhatId = currentAcct.id, Subject = currentAcct + ' conduct top account review' ); newTasks.add(t); // use DML to save the ‘newTasks’ list of task //sObjects to Salesforce Insert newTasks; Building Block: Data Manipulation Language (DML) DML sends data TO Salesforce action list to perform action on insert update delete upsert undelete DML Statements DML Salesforce Task object
  28. 28. Classes, Variables, and Methods sObjects Triggers Lists & For Loops Data Manipulation Language (DML) Salesforce Object Query Language (SOQL) Building Blocks of Coding
  29. 29. SOQL pulls data OUT of Salesforce SELECT - What fields do you want? FROM - Where are these fields stored? WHERE - What filters do you want to use? Building Block: Salesforce Object Query Language SELECT Id, Name FROM account WHERE id = '0012E0000012yU6QAI' fields you want location of fields your filters SOQL Salesforce Account object data matching your query
  30. 30. Governor Limits & Bulkification Who used all the hot water?! Arrrg! This shower is cold! Really? Again! I’m lukewarm mad! La la la! I love my looong hot showers!
  31. 31. Bulkification in Action public class AccountUtility { public static void calculateValue(List<Account> newAccountsFromTrigger){ List<Task> newTasks = new List<Task>(); //create a List for(Account currentAcct : newAccountsFromTrigger){ //loop over accounts from trigger if(currentAcct.top_Account__c == TRUE ){ Task t = new Task( WhatId = currentAcct.id, Subject = currentAcct + ' conduct top account review' // we’d add more variables here ); newTasks.add(t); //add task ‘t’ to the list } //end if } //end for loop insert newTasks; //use DML to add records in list to Salesforce } //end method } //end class
  32. 32. Bulkification in Short No SOQL or DML in Loops
  33. 33. Summary ● Utility classes store all your business logic. They contain things like variables, methods, loops, DML, and SOQL ● Variables are like temporary fields -- they can be simple (e.g., string) or complex (sObject and lists). ○ sObjects are variables that store an entire Salesforce records ○ Lists are variables that store groups of simple or complex variables. ● Methods contain groups of code that make things happen. ● For loops take a collection (list) and do something to each member of the collection. ● Triggers listen to changes to your database and then fire off methods within classes ● SOQL queries your Salesforce org for data and DML saves data to Salesforce. ● Bulkification ensures that your code will run when you’re working with lots of records.
  34. 34. Resources Trailhead ● Build Apex Coding Skills (Trail) ○ Apex Basics for Admins (Module) ○ Object-Oriented Programming for Admins (Module) Trailblazer Community Groups ● Local or remote developer user groups Presentation Recording ● Intro to Object Oriented Programming (OOP) for Admins Websites ● http://radwomen.org ● http://sfdc99.com ● http://WomenCodeHeroes.com ● http://archladies.com
  35. 35. Q&A bit.ly/AdminWebinarGroup Slides bit.ly/programmingbuildingblocks Wrapping Up Survey Please complete GoToWebinar survey

×