Programming Building Blocks for Admins Webinar Recap

By

Our last webinar, Programming Building Blocks for Admins, is part of our Back to School webinar series where we cover technical skill development as well as the latest product updates. Director of Trailhead Content Engineering Kieren Jameson and Senior Content Writer Angelica Morriesette shared their expertise to help you get a basic understanding of the core building blocks of programming on the Salesforce Platform.

Take a look at the full recording:

Webinar Summary:

The scenario we use in the webinar as we move through the nine building blocks involves a fictional company called BOTanicals. Kieren describes the company’s Salesforce data model which has two standard objects—accounts and tasks— and how she wants to trigger the creation of a task to conduct a review of top accounts.

Classes, Variables, and Methods

From here, we learn about the first set of building blocks: classes, variables, and methods. To think about it in non-code terms: Classes contain the code-based business logic in your org, and those classes have variables and methods. Variables are like fields, and methods are like quick actions.

 

Kieren starts by explaining how #AwesomeAdmins can easily go about creating a class, method, or variable and what each would be best used for. Take a look at her code breakdowns:

Next, we have methods, or the code that lives inside the class. It should be easy to identify what you’re looking at or working on in this section because all methods have an open and closed parenthesis. This is where the data being used to feed the method lives.

sObjects

sObjects are variables that store entire Salesforce records! We start by looking at two different types of sObjects that will help create the solution needed for BOTanicals: an Account sObject and a Task sObject.

But before we get to creating, Kieren breaks down the variables that make up the sObject and store the data in that record. She says, “If you’ve ever created a task, then you know that there are multiple fields you can add to the task object… The same fields that you see in the UI when creating a task are the very same variables associated with an sObject.” And just like every field has a data type, so do variables. Check out the example:

And now, we have everything we need to create an Account sObject with Apex!

Triggers

Next, Angelica covers how we can get all of this code working with the building blocks that Kieren introduced. And the answer to that is: Triggers. Triggers are what kick off code-based automated processes in Salesforce. Once a trigger recognizes that a record is being modified, the method that is created outside of the trigger runs. Angelica explains, “Triggers can be considered the air traffic controllers of your code.” And, best practice alert! Treat triggers like a table of contents for your code and keep your business logic in classes, not triggers, so your code can be reused. Also, when you are creating, be sure that you only have one trigger per object; otherwise, you won’t be able to control the order in which the actions fire.

Take a look at how Angelica creates a trigger in Apex:

Lists and For Loops

There are a few more Apex building blocks that will help your code run more efficiently, namely Lists and For Loops. First up, Lists. Now, these aren’t to-do lists or grocery lists, but they are similar. Lists are groups of one type of thing that sort together under one variable name. Lists and For Loops go hand-in-hand, as For Loops are used to look through individual things in a List and then take action on each thing.

Take a look through Angelica’s snippet of code to see how all the building blocks, including Lists and For Loops, work together so far:

Data Manipulation Language (DML)

So far, nothing has actually happened in our org. But we want to be able to see what we’re doing inside of our org when we’re ready to take action, and to do that we use Data Manipulation Language (DML). DML sends data to Salesforce with simple keywords that indicate which action you want performed as well as which List of sObjects you want that action performed on. In this webinar, Angelica uses “insert”, but other common DML statements include “update”, “delete”, “upsert”, and “undelete”.

SOQL

Now we move on to the final Apex building block: SOQL (pronounced “sock-uhl” or “soak-uhl” depending on who you speak to), which stands for Salesforce Object Query Language. It’s how you query your database, or pull data out of Salesforce. SOQL has a three-part structure of “select, from, where” statements. Angelica explains that this is actually very similar to creating a report and that, just like in a report, you say which object you want data from, which fields you want to display, and which filters you want to add. Now, when we talk about SOQL, we also have to cover governor limits and bulkification because both SOQL and DML use up your org’s resources. To better understand this concept, listen to Angelica’s analogy:

Wow! That was a ton of awesome information. Your mind is probably turning and excited to put these practices into action. So, where do you go from here? Check out these awesome resources from Kieren and Angelica:

http://radwomen.org
http://sfdc99.com
http://WomenCodeHeroes.com
http://archladies.com

Want to see more good stuff? Subscribe to our channel!

SUBSCRIBE TODAY
The fun way to learn
Get familiar with Apex and expand your admin toolkit.
Leverage flows to process inbound emails with documents

Leverage Flows To Process Inbound Emails With Documents | Automate This!

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, let’s see how Ohad Idan vanquishes shared […]

READ MORE
Improve sales funnel velocity with Flow

Improve Sales Funnel Velocity Using Flow | Automate This!

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, learn how Becka Dente leverages a simple […]

READ MORE
Send a dynamic email to user-defined contacts with flow

Send a Dynamic Email to User-Defined Contacts Using Flow | Automate This!

Welcome to another “Automate This!” In this live-streamed video series, we cover all things automation, from use cases and best practices to showcasing solutions built by Awesome Admin Trailblazers like you. With automation, you can remove manual tasks, drive efficiency, and eliminate friction and redundancy. In this episode, learn how Michael Barnes uses Flow to […]

READ MORE