Skip to content

Instantly share code, notes, and snippets.

trigger StockItemTrigger on Stock_Item__c (before insert, before delete) {
//Instantiate StockItemHandler
//Before Insert Handling
if(Trigger.isInsert && Trigger.isBefore) {
//call the class in your handler for before insert
StockItemHandler.checkDuplicateName(Trigger.new);
}
/**
* A Utility class to process Stock Item records from the Stock Item Handler
*/
public with sharing class StockItemHandler {
/**
* Class constructor.
*/
public StockItemHandler() {
public with sharing class AccountTriggerHandler {
public static void handleBeforeInsert(List<Account> newAccounts){
for (Account a : newAccounts) {
if (a.Est_Annual_Sales__c >= 5000000) {
a.Priority__c = 'Highest';
} else if (a.Est_Annual_Sales__c >= 3000000) {
a.Priority__c = 'High';
} else if (a.Est_Annual_Sales__c >= 1000000) {
public with sharing class WeekSixHomework {
public static void soqlPractice() {
//1. Below is a SOQL query that should be returning the top 5 Accounts in our org based on Annual Revenue.
//Something's not quite right, can you fix the query?
List<Account> topFiveAccounts = [SELECT Id, Name, AnnualRevenue FROM Account
WHERE AnnualRevenue != 0
order By AnnualRevenue DESC
LIMIT 5];
public with sharing class WeekFiveHomework {
public static void setsReview(){
//Your assignment: Play with Sets!
// 1. Create a set of Strings and add at least 5 entries
Set<String> Colors = new Set<String>();
Colors.add('Pink');
public with sharing class WeekFourHomework {
//Let's practice calling different methods by writing our very own methods. You will write and save methods in the space below
//that call the existing methods you see already written here. Ready? Let's Go!
//Sample: Here is a public method that calls the getCitiesForExpansion below and prints the results to our debug log
public static void printOutCitiesForExpansionDemo() {
//The code on the left of the equals sign instantiates a list of Strings, the code on the right side calls our method and returns a list of cities
//the equals sign assigns the returrned vaule, to the list we created
public with sharing class CommentingOnCodeExercise {
/**
* Your Assignment is to add comments describing what is being done in the methods below.
* Call out the concepts you learned in your readings and in class.
*/
//This class is used to calculate the Carts Value and ask if we are meeting the minimum requiered value.
public static void cartValues() {
//Sets the minimum cart value to 50, this will be later used as a threshold to ensure we meet our task of filling the cart. We are using a variable and setting it to 50; later we will check to see if we are at or above 50
public with sharing class WeekTwoHomework {
public static void introToPrimitives() {
//Primitives are the simplest elements in a programming language
/* A selection of primitives in Apex:
Integer: A number that does not have a decimal point, like 1 or 789 or -34
Decimal: A number that includes a decimal point like 1.34 or 456.78907654
String: Any set of characters surrounded by single quotes, like 'Apple' or 'I Love Strings' or '2 Legit 2 Quit'
// Check you have peanut butter
// Check you have Jelly
// Check you have sandwich bread
Get a plate and 2 clean knives
Get two pieces of sandwich bread
Place both pieces of sandwich bread on the plate next to each other
Open Peanut Butter
Use 1 clean knife to take 3oz of peanut butter out of the jar
Spread the peanut butter on one side of one piece of bread
public with sharing class Welcome {
//Welcome! I'm a comment and I'm here to tell you what this particular class file is for. The developer who created this class added
//me so that future developers, like yourself, would have a quick little introduction to what this class does.
//The two little slashes tell the compiler* that everything following on this line is a note
//for humans and not code that needs to be executed
// (* A compiler is the computer program that translates this code into executable computer instructions)
//But you know what? This set of comments is already several lines long and getting longer. I'm tired of typing two slashes every time